[{"name":"Debounce","comment":" The `Debounce` type keeps track of messages it's received in a\nparticular burst. Every message added to the list schedules a check some time\nin the future; if the list hasn't changed in that time we emit the newest\nmessage in the list and discard the rest.\n\n\n# The Basics\n\n@docs Debounce, DebounceMsg, init, update\n\n\n# Usage\n\nTo use the Debounce module. First, you will need to define a `Debounce` in your model,\ninitialize it with `init` function, and `update` it in your update function.\n\nThen the actual debounce functionality is provided either in your update function using\n[`Debounce.push`](#push) or in your HTML using one of the Debounce [events'](#events)\nfunctions.\n\nThe difference between the two is that the `push` function is used when you **DO** want to\ncapture some data from the event source as they occur, while `events` functions are used\nwhen you **DO NOT** want to capture data from the event source as they occur.\n\n**Example**: Suppose you want search an API in realtime as the user types,\nor developing an autocomplete feature that gets results from an API as the user types. You\nneed the text input to be updated as the user types. However, Http request needs to be sent\nto the API when the user stops typing.\n\n[`Debounce.push`](#push) is perfect fit as it will allow you to capture and update the text\ninput as the user types, and then send the Http request when the user stops typing.\n\nIf you use [events](#events) in this case, you will not be able to capture the text input\nas the user types.\n\n**Example** : a pagination component that sends out a HTTP request on page change, we want\nto prevent a sudden burst of requests being sent if the user clicks the \"next page\" button\nmultiple times.\n\nIn this case, one of the Debounce events such as `Debounce.event` would be a perfict fit\nas opposed to `Debounce.push` as\n\n  - It doesn't need any data comeing from the event source.\n\n  - It applies the debouncing functionality right in HTML without cluttering up the `update`\n    function unnecessarily.\n\n```elm\nbutton\n    [ Debounce.event onClick NextPage model.debouncer ]\n    [ Html.text \">>\" ]\n```\n\n\n# Push\n\n@docs push\n\n\n# Events\n\n\n## Debounce right at the source, in the HTML.\n\nThis is useful when you want to debounce events that are coming from the user, like clicks,\nkey presses, etc. It almost covers all the events that are available in Http.Events module.\n\nThis is useful when you **DO NOT** want to capture some data from the event source as they occur.\n\nIt produces an `Attribute msg` that can be used in the HTML.\n\nBoth `event` and `composeEvent` cover all elm events that are available in elm\n[Html.Events](https://package.elm-lang.org/packages/elm/html/latest/Html-Events) module.\n\n`on`, `alwaysPreventDefaultOn`, `alwatsStopPropagationOn`, and `custom` allow you create custom events with custom\ndecoders. This is useful when you want to debounce custom events that are not available in\nthe Html.Events module like `mousemove`, `scroll`, etc.\n\n@docs event, composeEvent, on, alwaysPreventDefaultOn, alwatsStopPropagationOn, custom\n\n","unions":[{"name":"Debounce","comment":" A type for the Debouncer that keeps track of messages it's received in a\nparticular burst. When that burst settles after the provided cooldown period,\nthe newest meesage gets emitted.\n\n    -- define a debouncer in your component\n    type alias Model =\n        { inputText : String\n        , debouncer : Debounce Msg\n        }\n\n","args":["msg"],"cases":[["Debounce",["{ cooldown : Basics.Int, queue : List.List msg, tagger : Debounce.DebounceMsg msg -> msg }"]]]},{"name":"DebounceMsg","comment":" A type for messages internal to the Debounce.\n\n    -- define a `Debounce.DebounceMsg Msg` type in your component\n    type Msg\n        = DebounceMsg (Debounce.DebounceMsg Msg)\n        | ...\n\n","args":["msg"],"cases":[]}],"aliases":[],"values":[{"name":"alwatsStopPropagationOn","comment":" Similar to `on` it debounces custom events with custom decoders but it always stopPropagation.\n","type":"String.String -> Json.Decode.Decoder msg -> Debounce.Debounce msg -> Html.Attribute msg"},{"name":"alwaysPreventDefaultOn","comment":" Similar to `on` it debounces custom events with custom decoders but it always preventDefault.\n","type":"String.String -> Json.Decode.Decoder msg -> Debounce.Debounce msg -> Html.Attribute msg"},{"name":"composeEvent","comment":" Debounce any event with `((a -> msg) -> Attribute msg)` definition\n\nIt composes event `(a -> msg) -> Attribute msg` with Msg `(a -> msg)`\nto give you the final `Attribute msg` while applying the debounce functionality.\n\n    -- Usage\n\n    Input\n        [ type \"text\"\n        , Debounce.composeEvent onInput UpdateText model.debouncer\n        ]\n        []\n\n","type":"((a -> msg) -> Html.Attribute msg) -> (a -> msg) -> Debounce.Debounce msg -> Html.Attribute msg"},{"name":"custom","comment":" Similar to `Html.Events.custom` but it allows you to debounce custom events with custom decoders while controlling stopPropagation and preventDefault.\n","type":"String.String -> Json.Decode.Decoder { message : msg, stopPropagation : Basics.Bool, preventDefault : Basics.Bool } -> Debounce.Debounce msg -> Html.Attribute msg"},{"name":"event","comment":" `event` allows you to debounce any HTML event with `(msg -> Attribute msg)` definition\nsuch as `onClick`, `onMouseDown`, etc.\n\n    type alias Model =\n        { debouncer : Debounce Msg\n        , ...\n        }\n\n    type Msg\n        = DoSomething\n        | DebounceMsg (Debounce.DebounceMsg Msg)\n        | ...\n\n    init : Model\n    init =\n        { debouncer = Debounce.init DebounceMsg 500\n        , ...\n        }\n\n    update : Msg -> Model -> ( Model, Cmd Msg )\n    update msg model =\n        case msg of\n            DoSomething ->\n                ( model\n                , Http.get\n                    { ...\n                    }\n                )\n\n            DebounceMsg DebounceMsg ->\n                Debounce.update DebounceMsg model.debouncer\n                    |> Tuple.mapFirst (\\debouncer -> { model | debouncer = debouncer })\n\n    view : Model -> Html Msg\n    view model =\n        button\n            [ Debounce.event onClick DoSomething model.debouncer ]\n            [ Html.text \"Click\" ]\n\n","type":"(msg -> Html.Attribute msg) -> msg -> Debounce.Debounce msg -> Html.Attribute msg"},{"name":"init","comment":" You will need to provide a `tagger` function that will wrap the `DebounceMsg`\nand a `cooldown` value that will determine how long the Debouncer will wait before\nchecking if the burst has settled.\n\n    init : () -> ( Model, Cmd Msg )\n    init _ =\n        ( { inputText = \"\"\n          , debouncer = Debounce.init DebounceMsg 500\n          }\n        , Cmd.none\n        )\n\n","type":"(Debounce.DebounceMsg msg -> msg) -> Basics.Int -> Debounce.Debounce msg"},{"name":"on","comment":" Debounce custom events with custom decoders.\nThis is useful when you want to debounce custom events that are not available in the Html.Events module like `mousemove`.\n\n    -- Eg: do something when the mouse moves stops\n\n    mousemoveDecoder : (Int -> Int -> msg) -> Decode.Decoder msg\n    mousemoveDecoder msg =\n        Decode.map2 msg\n            (Decode.field \"clientX\" Decode.int)\n            (Decode.field \"clientY\" Decode.int)\n\n    div\n        [ Debounce.on \"mousemove\" (mousemoveDecoder GotPosition) model.debouncer ]\n        []\n\n","type":"String.String -> Json.Decode.Decoder msg -> Debounce.Debounce msg -> Html.Attribute msg"},{"name":"push","comment":" Push a messages into the Debouncer. Every message added to the list schedules a check\nsome time in the future. If the list hasn't changed in that time, we emit the newest message\nin the list and discard the rest.\n\nThis is useful when you **DO** want to capture some data from the event source as they occur.\n\n    -- define a debouncer in your component\n    type alias Model =\n        { inputText : String\n        , debouncer : Debounce Msg\n        }\n\n    -- define a `Debounce.DebounceMsg Msg` type in your component\n    type Msg\n        = UpdateInputText String\n        | SendRequest String\n        | DebounceMsg (Debounce.DebounceMsg Msg)\n\n\n    -- init\n    init : () -> ( Model, Cmd Msg )\n    init _ =\n        ( { inputText = \"\"\n          , debouncer = Debounce.init DebounceMsg 500\n          }\n        , Cmd.none\n        )\n\n    -- update\n    update : Msg -> Model -> (Model, Cmd Msg)\n    update msg model =\n        case msg of\n            ...\n            UpdateInputText text ->\n                Debounce.push (SendRequest text) model.debouncer\n                    |> Tuple.mapFirst\n                        (\\debouncer ->\n                            { model\n                                | debouncer = debouncer\n                                , inputText = text\n                            }\n                        )\n\n            SendRequest text ->\n                ( model\n                , Http.get\n                    { ...\n                    }\n                )\n\n            DebounceMsg debounceMsg ->\n                Debounce.update debounceMsg model.debouncer\n                    |> Tuple.mapFirst\n                        (\\debouncer ->\n                            { model\n                                | debouncer = debouncer\n                            }\n                        )\n\n\n\n    -- view\n    view : Model -> Html Msg\n    view model =\n        input\n            [ type_ \"text\"\n            , value model.inputText\n            , onInput UpdateInputText\n            ]\n            []\n\n","type":"msg -> Debounce.Debounce msg -> ( Debounce.Debounce msg, Platform.Cmd.Cmd msg )"},{"name":"update","comment":" The update function produces Cmds like any other update function. You will\nneed to use it for every Debouncer you have in an application in order for\nthe `Debounce` to handle its internal messages.\n\n    update : Msg -> Model -> (Model, Cmd Msg)\n    update msg model =\n        case msg of\n            ...\n            DebounceMsg debounceMsg ->\n                Debounce.update debounceMsg model.debouncer\n                    |> Tuple.mapFirst (\\debouncer -> { model | debouncer = debouncer })\n\n","type":"Debounce.DebounceMsg msg -> Debounce.Debounce msg -> ( Debounce.Debounce msg, Platform.Cmd.Cmd msg )"}],"binops":[]},{"name":"Throttle","comment":" A Throttler limits messages by only allowing messages to come in as fast\nas a fixed interval allows. When receive a burst of messages, the first one\nwill pass through the emitter and then all messages are ignored for a period of\ntime, then the next message will pass through and so on.\n\nWhen events are throttled using one of the Throttle events' functions, the module\ndoesnt just send a **`NoOp`** message, instead it blocks any messages by deregistering\nthe event listener. This is to avoid unnecessary messages being sent to the update\nfunction and the elm runtime.\n\n\n# The Basics\n\n@docs Throttle, ThrottleMsg, init, update\n\n\n# Usage\n\nTo use the Throttle module. First, you will need to define a `Throttle` in your model,\ninitialize it with `init` function, and `update` it in your update function.\n\nThen the actual throttle functionality is provided either in your update function using\n[`Throttle.push`](#push) or in your HTML using one of the Throttle [events'](#events)\nfunctions.\n\nThe difference between the two is that the `push` function is used when you **DO** want to\ncapture some data from the event source as they occur, while `events` functions are used\nwhen you **DO NOT** want to capture data from the event source as they occur.\n\n**Example**: Suppose you want log information about the user's mouse position, you need\nthe logging to be throttled. You also need to keep track of the mouse position for some\nanimation functionality.\n\n[`Throttle.push`](#push) is perfect fit as it will throttle the log message but still\nkeep track of the mouse position data as they occur.\n\nIf you use [events](#events) like the following, the emitted Msg `GotPosition` will be\nthrottled and you will loose the mouse position data as they occur.\n\n    Throttle.on \"mousemove\" (decoder GotPosition) model.throttler\n\n\n# Push\n\n\n## Throttle from the update function.\n\nThis is useful when you **DO** want to capture some data from the event source as they occur.\n\n@docs push\n\n\n# Events\n\n\n## Throttle right at the source, in the HTML.\n\nThis is useful when you want to throttle events that are coming from the user,\nlike clicks, key presses, etc. It almost covers all the events that are available\nin Http.Events module.\n\nIt produces an `Attribute msg` that can be used in the HTML.\n\nThis is useful when you **DO NOT** want to capture some data from the event source as they occur.\n\nBoth `event` and `composeEvent` cover all elm events that are available in elm\n[Html.Events](https://package.elm-lang.org/packages/elm/html/latest/Html-Events) module.\n\n`on`, `alwaysPreventDefaultOn`, `alwaysStopPropagationOn`, and `custom` allow you create custom events\nwith custom decoders. This is useful when you want to throttle custom events that\nare not available in the Html.Events module like `mousemove`, `scroll`, etc.\n\n@docs event, composeEvent, on, alwaysPreventDefaultOn, alwaysStopPropagationOn, custom\n\n","unions":[{"name":"Throttle","comment":" A type for `Throttler` that limits messages by only allowing messages to come in\nas fast as a fixed interval allows. When receive a burst of messages, the first one\nwill pass through the emitter and then all messages are ignored for a period of\ntime, then the next message will pass through and so on.\n\n    -- define Throttler in your component\n    type alias Model =\n        { throttler : Throttle Msg\n        , ...\n        }\n\n","args":["msg"],"cases":[["Throttle",["{ interval : Basics.Int, status : Throttle.Status, tagger : Throttle.ThrottleMsg msg -> msg }"]]]},{"name":"ThrottleMsg","comment":" A type for messages internal to the Debounce.\n\n    -- define (Throttle.ThrottleMsg Msg) type in your component\n    type Msg\n        = DoSomething\n        | ThrottleMsg (Throttle.ThrottleMsg Msg)\n        | ...\n\n","args":["msg"],"cases":[]}],"aliases":[],"values":[{"name":"alwaysPreventDefaultOn","comment":" Similar to `on` it throttle custom events with custom decoders but it always preventDefault.\n","type":"String.String -> Json.Decode.Decoder msg -> Throttle.Throttle msg -> Html.Attribute msg"},{"name":"alwaysStopPropagationOn","comment":" Similar to `on` it throttle custom events with custom decoders but it always stopPropagation.\n","type":"String.String -> Json.Decode.Decoder msg -> Throttle.Throttle msg -> Html.Attribute msg"},{"name":"composeEvent","comment":" Throttle any event with `((a -> msg) -> Attribute msg)` definition\n\nIt composes event `(a -> msg) -> Attribute msg` with Msg `(a -> msg)`\nto give you the final `Attribute msg` while applying the throttle.\n\n    -- Usage\n\n    Input\n        [ type \"text\"\n        , Throttle.composeEvent onInput UpdateText model.throttler\n        ]\n        []\n\n","type":"((a -> msg) -> Html.Attribute msg) -> (a -> msg) -> Throttle.Throttle msg -> Html.Attribute msg"},{"name":"custom","comment":" Similar to `Html.Events.custom` but it allows you to throttle custom events with custom decoders while controlling stopPropagation and preventDefault.\n","type":"String.String -> Json.Decode.Decoder { message : msg, stopPropagation : Basics.Bool, preventDefault : Basics.Bool } -> Throttle.Throttle msg -> Html.Attribute msg"},{"name":"event","comment":" `event` allows you to throttle any event with `(msg -> Attribute msg)` definition\nsuch as `onClick`, `onMouseDown`, etc.\n\n    type alias Model =\n        { throttler : Throttle Msg\n        , ...\n        }\n\n    type Msg\n        = DoSomething\n        | ThrottleMsg (Throttle.ThrottleMsg Msg)\n        | ...\n\n    init : Model\n    init =\n        { throttler = Throttle.init ThrottleMsg 1000\n        , ...\n        }\n\n    update : Msg -> Model -> ( Model, Cmd Msg )\n    update msg model =\n        case msg of\n            DoSomething ->\n                ( model, Cmd.none )\n\n            ThrottleMsg throttleMsg ->\n                Throttle.update throttleMsg model.throttler\n                    |> Tuple.mapFirst (\\throttler -> { model | throttler = throttler })\n\n    view : Model -> Html Msg\n    view model =\n        button\n            [ Throttle.event onClick DoSomething model.throttler ]\n            [ Html.text \"Click\" ]\n\n","type":"(msg -> Html.Attribute msg) -> msg -> Throttle.Throttle msg -> Html.Attribute msg"},{"name":"init","comment":" You will need to provide a `tagger` function that will wrap the `ThrottleMsg`\nand an `interval` value that will pass before consecutive messages can be emitted.\n\n    -- initialize your Throttle\n    -- passing in the tagger function and the interval\n    init : Model\n    init =\n        { throttler = Throttle.init ThrottleMsg 5000\n        , ...\n        }\n\n","type":"(Throttle.ThrottleMsg msg -> msg) -> Basics.Int -> Throttle.Throttle msg"},{"name":"on","comment":" Throttle custom events with custom decoders. This is useful when you want to\nthrottle custom events that are not available in the Html.Events module like `mousemove`.\n\n    mousemoveDecoder : (Int -> Int -> msg) -> Decode.Decoder msg\n    mousemoveDecoder msg =\n        Decode.map2 msg\n            (Decode.field \"clientX\" Decode.int)\n            (Decode.field \"clientY\" Decode.int)\n\n    div\n        [ Throttle.on \"mousemove\" (mousemoveDecoder GotPosition) model.throttler ]\n        []\n\n","type":"String.String -> Json.Decode.Decoder msg -> Throttle.Throttle msg -> Html.Attribute msg"},{"name":"push","comment":" Push a messages into the Throttle. This is useful when you **DO** want to capture some\ndata from the event source as they occur. When the Throttle receives a burst of messages,\nthe first one will pass through the emitter and then all messages are ignored for a period of time,\nthen the next message will pass through and so on.\n\n    type alias Position =\n        { x : Int\n        , y : Int\n        }\n\n    -- define your model\n    type alias Model =\n        { throttler : Throttle Msg\n        , position : Position\n        , ...\n        }\n\n    -- define your Msg type\n    type Msg\n        = GotPosition x y\n        | LogMsg x y\n        | ThrottleMsg (Throttle.ThrottleMsg Msg)\n        | ...\n\n\n    -- initialize your Model\n    init : Model\n    init =\n        { throttler = Throttle.init ThrottleMsg 5000\n        , Position 0 0\n        , ...\n        }\n\n\n    -- update\n    update : Msg -> Model -> ( Model, Cmd Msg )\n    update msg model =\n        case msg of\n            GotPosition x y ->\n                Throttle.push (LogMsg x y) model.throttler\n                    |> Tuple.mapFirst\n                        (\\throttler ->\n                            { model\n                                | throttler = throttler\n                                , position = { x = x, y = y }\n                            }\n                        )\n\n            LogMsg x y ->\n                ( model\n                , Http.post\n                    { ...\n                    }\n                )\n\n            ThrottleMsg throttleMsg ->\n                Throttle.update throttleMsg model.throttler\n                    |> Tuple.mapFirst (\\throttler -> { model | throttler = throttler })\n\n\n    -- view\n    view : Model -> Html Msg\n    view model =\n        div\n            [ on \"mousemove\" (mouseMoveDecoder GotPosition) ]\n            [...\n            ]\n\n    -- mousemove decoder\n    mouseMoveDecoder GotPosition =\n        Decode.map2 GotPosition\n            (Decode.field \"clientX\" Decode.int)\n            (Decode.field \"clientY\" Decode.int)\n\nHere the `GotPosition` message will Not be throttled and it will capture the mouse position as the mouse moves,\nhowever the `LogMsg` will be throttled.\n\n","type":"msg -> Throttle.Throttle msg -> ( Throttle.Throttle msg, Platform.Cmd.Cmd msg )"},{"name":"update","comment":" The update function produces Cmds like any other update function. You will\nneed to use it for every Throttler you have in an application in order for\nthe `Throttle` to handle its internal messages.\n\n    update : Msg -> Model -> ( Model, Cmd Msg )\n    update msg model =\n        case msg of\n            DoSomething ->\n                ( model, Cmd.none )\n\n            ThrottleMsg throttleMsg ->\n                Throttle.update throttleMsg model.throttler\n                    |> Tuple.mapFirst (\\throttler -> { model | throttler = throttler })\n\n","type":"Throttle.ThrottleMsg msg -> Throttle.Throttle msg -> ( Throttle.Throttle msg, Platform.Cmd.Cmd msg )"}],"binops":[]}]