mirror of
https://github.com/correl/elm-exercise.git
synced 2024-11-27 11:09:53 +00:00
27 lines
382 B
Elm
27 lines
382 B
Elm
|
module Demo.Connection (..) where
|
||
|
|
||
|
|
||
|
type State
|
||
|
= Online
|
||
|
| Connecting
|
||
|
| Offline
|
||
|
|
||
|
type Action
|
||
|
= Connect
|
||
|
| Connected
|
||
|
| Disconnect
|
||
|
|
||
|
|
||
|
update : Action -> State -> State
|
||
|
update action state =
|
||
|
case (state, action) of
|
||
|
(Offline, Connect) ->
|
||
|
Connecting
|
||
|
(Connecting, Connected) ->
|
||
|
Online
|
||
|
(Online, Disconnect) ->
|
||
|
Offline
|
||
|
_ ->
|
||
|
state
|
||
|
|