While building an app via this library stumbled upon a problem that I can't completely understand. Should the stream handling function be designed assuming the input model/state parameter is the actual/current state or the initial one? As I understand this code, it should get the updated state. But in my app the stream's state parameter always retains the initial value.
Example
The example is simplistic and meaningless -- it is just for demo purpose.
Brief explanation
The state contains SavedInput : string option, that is taken from HTML Input element after clicking "Save" button.
The messages are SaveNewInput of string , UpperCase and LowerCase. The 1st one is simply propagated from the stream, the last two are ignored if SavedInput is None:
messages
|> AsyncRx.choose (function
| SaveNewInput _ as msg -> Some msg
| UpperCase
| LowerCase as msg ->
state.SavedInput
|> Option.map (fun _ -> msg)
The intent is to ignore the messages UpperCase and LowerCase until user saves an entered string. So if the stream function obtained the actual state, the example would work properly. However in reality it always ignores UpperCase and LowerCase messages, because the stream function never gets an updated state -- it always has the initial value.
So this is the problem I want to clarify.
While building an app via this library stumbled upon a problem that I can't completely understand. Should the stream handling function be designed assuming the input model/state parameter is the actual/current state or the initial one? As I understand this code, it should get the updated state. But in my app the stream's state parameter always retains the initial value.
Example
The example is simplistic and meaningless -- it is just for demo purpose.
Brief explanation
The state contains
SavedInput : string option, that is taken from HTML Input element after clicking "Save" button.The messages are
SaveNewInput of string,UpperCaseandLowerCase. The 1st one is simply propagated from the stream, the last two are ignored ifSavedInputisNone:The intent is to ignore the messages
UpperCaseandLowerCaseuntil user saves an entered string. So if the stream function obtained the actual state, the example would work properly. However in reality it always ignoresUpperCaseandLowerCasemessages, because the stream function never gets an updated state -- it always has the initial value.So this is the problem I want to clarify.