Allow for non-string values in responses, and ports.
This commit is contained in:
@@ -46,7 +46,7 @@ type Msg =
|
||||
| ReceiveLoginResponse ApiUrl (Result Http.Error LoginResponse) -- HTTP, Login has finished
|
||||
| ReceiveUserData Username (Result Http.Error UserData)
|
||||
| ReceiveCompletedReadMarker (Result Http.Error ())
|
||||
| ReceiveStoreData StoreData
|
||||
| ReceiveStoreData Json.Decode.Value
|
||||
|
||||
displayName : Model -> Username -> String
|
||||
displayName m s = Maybe.withDefault (senderName s) <| Maybe.andThen .displayName <| Dict.get s m.userData
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
port module Scylla.Storage exposing (..)
|
||||
import Json.Encode
|
||||
import Json.Decode as Decode exposing (Decoder, int, string, float, list, value, dict, bool)
|
||||
import Json.Decode.Pipeline exposing (required, optional)
|
||||
|
||||
type alias StoreData =
|
||||
{ key : String
|
||||
, value: String
|
||||
, value: Decode.Value
|
||||
}
|
||||
|
||||
storeDataDecoder : Decoder StoreData
|
||||
storeDataDecoder = Decode.succeed StoreData
|
||||
|> required "key" string
|
||||
|> required "value" value
|
||||
|
||||
port setStoreValuePort : (String, Json.Encode.Value) -> Cmd msg
|
||||
port getStoreValuePort : (String) -> Cmd msg
|
||||
port receiveStoreValuePort : (StoreData -> msg) -> Sub msg
|
||||
port receiveStoreValuePort : (Json.Encode.Value -> msg) -> Sub msg
|
||||
|
||||
Reference in New Issue
Block a user