[{"name":"TaskPort","comment":" This module allows to invoke JavaScript functions using the Elm's Task abstraction,\nwhich is convenient for chaining multiple API calls without introducing the complexity\nin the model of an Elm application.\n\n# Setting up\nBefore TypePort can be used in Elm, it must be set up on JavaScript side.\nRefer to the [README](https://github.com/lobanov/elm-taskport/blob/main/README.md) for comprehensive instructions.\n\n# Usage\n@docs call, callNoArgs, Error, InteropError\n\n# Tests\nWe are exposing tests suite to help test module's implementation details.\n@docs tests\n\n","unions":[{"name":"Error","comment":" A structured error describing exactly how the interop call failed. You can use\nthis to determine the best way to react to and recover from the problem.\n\nCallError prefix is for errors explicitly sent from the JavaScript side. The error information\nwill be specific to the interop use case, and it should be reconsituted from a JSON payload.\n\nInteropError prefix is for the failures of the interop mechanism itself.\n","args":["x"],"cases":[["InteropError",["TaskPort.InteropError"]],["CallError",["x"]]]},{"name":"InteropError","comment":" Subcategory of errors indicating a failure of the interop mechanism itself.\nThese errors are generally not receoverable, but you can use them to allow the application to fail gracefully,\nor at least provide useful context for debugging.\n","args":[],"cases":[["FunctionNotFound",[]],["NotInstalled",[]],["VersionMismatch",[]],["CannotDecodeResponse",["Json.Decode.Error","String.String"]],["CannotDecodeError",["Json.Decode.Error","String.String"]],["RuntimeError",["String.String"]]]}],"aliases":[],"values":[{"name":"call","comment":" Creates a Task encapsulating an invocation of a particular asyncronous JavaScript function.\nThis function will usually be wrapped into a more specific one, which will partially apply it\nproviding the encoder and the decoders but curry the last parameter, so that it could invoked where necessary\nas a `args -> Task` function.\n\nBecause interop calls can fail, produced task would likely need to be piped into a `Task.attempt` or handled further using `Task.onError`.\n\nHere is a simple example that creates a `Cmd` invoking a registered JavaScript function called `ping`\nand produces a message `GotPong` with a `Result`, containing either an `Ok` variant with a string (determined by the first decoder argument),\nor an `Err`, containing a `TaskPort.Error` describing what went wrong.\n\n    type Msg = GotWidgetName (Result String String)\n\n    TaskPort.call \"getWidgetNameByIndex\" Json.Decode.string Json.Decode.string Json.Encode.int 0\n        |> Task.attempt GotWidgetName\n\nThe `Task` abstraction allows to effectively compose chains of tasks without creating many intermediate variants in the Msg type, and\ndesigning the model to deal with partially completed call chain. The following example shows how this might be used\nwhen working with a hypothetical 'chatty' JavaScript API, requiring to call `getWidgetsCount` function to obtain a number\nof widgets, and then call `getWidgetName` with each widget's index to obtain its name.\n\n    type Msg = GotWidgets (Result String (List String))\n    \n    TaskPort.callNoArgs \"getWidgetsCount\" Json.Decode.int Json.Decode.string\n        |> Task.andThen\n            (\\count ->\n                List.range 0 (count - 1)\n                    |> List.map Json.Encode.int\n                    |> List.map (TaskPort.call \"getWidgetNameByIndex\" Json.Decode.string Json.Decode.string)\n                    |> Task.sequence\n            )\n        |> Task.attempt GotWidgets\n\nThe resulting task has type `Task (TaskPort.Error String) (List String)`, which could be attempted as a single command,\nwhich, if successful, provides a handy `List String` with all widget names.\n","type":"String.String -> Json.Decode.Decoder body -> Json.Decode.Decoder error -> (args -> Json.Encode.Value) -> args -> Task.Task (TaskPort.Error error) body"},{"name":"callNoArgs","comment":" Special version of the `call` that reduces amount of boilerplate code required when calling JavaScript functions\nthat don't take any parameters. It is eqivalent of passing `Json.Encoder.null` into the `call`.\n\n    type Msg = GotWidgetsCount (Result String Int)\n\n    TaskPort.callNoArgs \"getWidgetsCount\" Json.Decode.int Json.Decode.string\n        |> Task.attempt GotWidgetsCount\n","type":"String.String -> Json.Decode.Decoder body -> Json.Decode.Decoder error -> Task.Task (TaskPort.Error error) body"},{"name":"tests","comment":" This is an embedded tests suite allowing to test module-internal logic. No need to use this. ","type":"Test.Test"}],"binops":[]}]