{"id":21424371,"url":"https://github.com/jinjor/elm-debounce","last_synced_at":"2025-07-14T08:31:49.436Z","repository":{"id":52694800,"uuid":"71227550","full_name":"jinjor/elm-debounce","owner":"jinjor","description":"Yet another debouncer for Elm","archived":false,"fork":false,"pushed_at":"2021-04-20T20:17:20.000Z","size":126,"stargazers_count":43,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T05:35:06.407Z","etag":null,"topics":["debounce","elm","elm-debounce"],"latest_commit_sha":null,"homepage":"http://package.elm-lang.org/packages/jinjor/elm-debounce/latest/","language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jinjor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-18T08:45:01.000Z","updated_at":"2025-03-10T05:11:27.000Z","dependencies_parsed_at":"2022-08-21T17:40:42.315Z","dependency_job_id":null,"html_url":"https://github.com/jinjor/elm-debounce","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/jinjor/elm-debounce","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinjor%2Felm-debounce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinjor%2Felm-debounce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinjor%2Felm-debounce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinjor%2Felm-debounce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jinjor","download_url":"https://codeload.github.com/jinjor/elm-debounce/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinjor%2Felm-debounce/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265262624,"owners_count":23736433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debounce","elm","elm-debounce"],"created_at":"2024-11-22T21:21:35.736Z","updated_at":"2025-07-14T08:31:48.816Z","avatar_url":"https://github.com/jinjor.png","language":"Elm","funding_links":[],"categories":["Elm"],"sub_categories":[],"readme":"# elm-debounce\n\nYet another debouncer for Elm.\n\n## How to use\n\nThis library follows the Elm Architecture. See the full example [here](https://github.com/jinjor/elm-debounce/blob/master/examples/Main.elm).\n\n```elm\ninit : ( Model, Cmd Msg )\ninit =\n  ( { value = \"\"\n    -- Initialize the debouncer.\n    , debounce = Debounce.init\n    , report = []\n    }\n  , Cmd.none\n  )\n\n\ntype Msg\n  = Input String\n  | DebounceMsg Debounce.Msg\n  ...\n\n\n-- This defines how the debouncer should work.\n-- Choose the strategy for your use case.\ndebounceConfig : Debounce.Config Msg\ndebounceConfig =\n  { strategy = Debounce.later 1000\n  , transform = DebounceMsg\n  }\n\n\nupdate : Msg -\u003e Model -\u003e (Model, Cmd Msg)\nupdate msg model =\n  case msg of\n    Input s -\u003e\n      let\n        -- Push your values here.\n        (debounce, cmd) =\n          Debounce.push debounceConfig s model.debounce\n      in\n        ( { model\n            | value = s\n            , debounce = debounce\n          }\n        , cmd\n        )\n\n    -- This is where commands are actually sent.\n    -- The logic can be dependent on the current model.\n    -- You can also use all the accumulated values.\n    DebounceMsg msg -\u003e\n      let\n        (debounce, cmd) =\n          Debounce.update\n            debounceConfig\n            (Debounce.takeLast save)\n            msg\n            model.debounce\n      in\n        ( { model | debounce = debounce }\n        , cmd\n        )\n\n    ...\n```\n\n### Multiple Debouncers\n\nIf you need to debounce multiple event sources, one approach is to repeat the pattern demonstrated above for each event source. For example, you could define a debouncer and debounce msg for each:\n\n```elm\ninit : ( Model, Cmd Msg )\ninit =\n  ( { value = \"\"\n    -- Initialize *multiple* debouncers.\n    , fooDebouncer = Debounce.init\n    , barDeboucner = Debounce.init\n    , report = []\n    }\n  , Cmd.none\n  )\n\ntype Msg\n  = InputFoo String\n  | InputBar String\n  | DebounceFoo Debounce.Msg\n  | DebounceBar Debounce.Msg\n```\n\nYou can choose to either have different configs for each event source:\n\n```elm\nfooDebounceConfig : Debounce.Config Msg\nfooDebounceConfig =\n  { strategy = Debounce.later (1 * second)\n  , transform = DebounceFoo\n  }\n\nbarDebounceConfig : Debounce.Config Msg\nbarDebounceConfig =\n  { strategy = Debounce.manual\n  , transform = DebounceBar\n  }\n```\n\nOr to use the same config for both:\n\n```elm\ndebounceConfig : (Debounce.Msg -\u003e Msg) -\u003e Debounce.Config Msg\ndebounceConfig debounceMsg =\n    { strategy = Debounce.later (1 * second)\n    , transform = debounceMsg\n    }\n```\n\nNote that the above config function takes your specific debounce msg as it's argument, so for example you might do the following:\n\n```elm\nDebounce.push (debounceConfig DebounceFoo) fooValue model.fooDebouncer\n```\n\nA full example of this approach can be seen [here](https://github.com/jinjor/elm-debounce/blob/master/examples/MultipleDebouncers.elm).\n\n## LICENSE\n\nBSD-3-Clause\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjinjor%2Felm-debounce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjinjor%2Felm-debounce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjinjor%2Felm-debounce/lists"}