This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
We were not able to find the expected elm-package.json file at this tag.
Tag 4.0.1
Committed At 2019-08-22 14:48:04 UTC

Modules

    README

    Elm-Debouncer

    Use continutations for deboucing!

    import Debounce
    import Task exposing (Task)
    
    type Msg
      = PingFoo
      | PungFoo
      | DebouncerMsg (Debounce.Msg Msg)
    
    type alias Model =
      { something   : Foo
      , myDebouncer : Debounce.Model Msg
      }
    
    init : Model
    init =
      { something   = initFoo
      , myDebouncer = Debounce.init
      }
    
    mkCmd : a -> Cmd a
    mkCmd = Task.perform (Debug.crash << toString) identity << Task.succeed
    
    
    update : Msg
          -> Model
          -> (Model, Cmd Msg)
    update action model =
      case action of
        PingFoo -> model ! [mkCmd <| DebouncerMsg <| Debounce.Bounce <| mkCmd PungFoo]
        PungFoo -> pang model ! [] -- the past tense of ping or something
        DebouncerMsg a ->
          let (newDebouncer, eff) = updateDebouncer
                                      (500 * millisecond)
                                      a
                                      model.myDebouncer
          in  { model | myDebouncer = newDebouncer }
            ! [ Cmd.map (\r -> case r of
                                 Err a' -> DebouncerMsg a'
                                 Ok  a' -> a') eff ]