Open
Description
I am sending a Maybe Value
on a port in order to clear the localstorage key when it receives a null value (through sending a Nothing on logout). Trying to do the same in the following code:
encode : Cred -> Decode.Value
encode (Cred user tokenInfo) =
Encode.object
[ ( "user", User.encode user )
, ( "token", tokenInfoEncoder tokenInfo )
]
storeCredWith : Cred -> Cmd msg
storeCredWith cred =
storeCache (Just (encode cred))
simulateStoreCredWith : Cred -> ProgramTest.SimulatedEffect msg
simulateStoreCredWith cred =
SimulatedEffect.Ports.send "storeCache" (Just (encode cred))
logout : Cmd msg
logout =
storeCache Nothing
port storeCache : Maybe Value -> Cmd msg
fails with:
TYPE MISMATCH - The 2nd argument to `send` is not what I expect:
SimulatedEffect.Ports.send "storeCache" (Just (encode cred))
#^^^^^^^^^^^^^^^^^#
This `Just` call produces:
#Maybe Value#
But `send` needs the 2nd argument to be:
#Encode.Value#
is there a way to simulate this (ie Port.send a Maybe Value) ?