Skip to content

opsb/elm-debouncer-fx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elm-Debouncer-Fx

An effect manager for debouncing.

type alias Model =
    { textValue : String
    , settledTextValue : String
    }


init =
    ( { textValue = ""
      , settledTextValue = ""
      }
    , Cmd.none
    )


type Msg
    = OnTextInput String
    | OnSettle


subscriptions : Model -> Sub Msg
subscriptions model =
    Debouncer.settled 1000 "textBouncer" OnSettle


update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        OnTextInput text ->
            ( { model | textValue = text }, Debouncer.bounce "textBouncer" )

        OnSettle ->
            ( { model | settledTextValue = model.textValue }, Cmd.none )


view : Model -> Html Msg
view model =
    div []
        [ input [ placeholder "words...", onInput OnTextInput ] []
        , div [] [ text model.settledTextValue ]
        ]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages