Debounced Validation

type alias Model =
    { password : String }

type Msg =
    PasswordEntered String

{|- should only start validating if the player has not typed for 500 ms
update : Msg -> Model -> (Model, Cmd Msg)
update msg =
    case msg of
        NameEntered pass =
            { model |> validate pass, Cmd.none }


How can I validate the password only if the user has not typed for 500ms?


Subscribe to time passing, based on whether a password need to be debounced or not. Start counting down the ms that have passed and then update.

Further reading

Last updated