Add `StateManager` type
parent
a5af1c40a0
commit
3bf84a2a57
|
@ -0,0 +1,28 @@
|
|||
module Internal.Values.StateManager exposing (..)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Internal.Values.Event as Event exposing (Event)
|
||||
|
||||
type alias StateManager = Dict (String, String) Event
|
||||
|
||||
getStateEvent : String -> String -> StateManager -> Maybe Event
|
||||
getStateEvent eventType stateKey =
|
||||
Dict.get ( eventType, stateKey )
|
||||
|
||||
updateRoomStateWith : StateManager -> StateManager -> StateManager
|
||||
updateRoomStateWith = Dict.union
|
||||
|
||||
fromEventList : List Event -> StateManager
|
||||
fromEventList =
|
||||
List.filterMap
|
||||
(\event ->
|
||||
event
|
||||
|> Event.stateKey
|
||||
|> Maybe.map
|
||||
(\key ->
|
||||
( ( Event.contentType event, key ), event )
|
||||
)
|
||||
)
|
||||
>> Dict.fromList
|
||||
|
||||
|
Loading…
Reference in New Issue