We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
We need a function to wrap an action from a child update in a parent update, see https://forums.websharper.com/topic/87100:
module Action = let rec Map (wrapMsg: 'ChildMessage -> 'ParentMessage) (currentModel: 'ParentModel) (wrapModel: 'ParentModel -> 'ChildModel -> 'ParentModel) (unwrapModel: 'ParentModel -> 'ChildModel) (action: Action<'ChildMessage, 'ChildModel>) : Action<'ParentMessage, 'ParentModel> = match action with | DoNothing -> DoNothing | SetModel childModel -> UpdateModel (fun parent -> wrapModel parent childModel) | UpdateModel f -> UpdateModel (fun parent -> unwrapModel parent |> f |> wrapModel parent) | Command cmd -> Command (fun dispatch -> cmd (wrapMsg >> dispatch)) | CommandAsync cmd -> CommandAsync (fun dispatch -> cmd (wrapMsg >> dispatch)) | CombinedAction actions -> CombinedAction (List.map (Map wrapMsg currentModel wrapModel unwrapModel) actions) // Use: let update msg (state: State) : Action<Message, State> = match msg with | TagListMessage m -> let updatedTagList= Tags.update m state.TagList SetModel {state with TagList=updatedTagList} | AuthMessage m -> Authentication.update m state.UserInfo |> Action.Map AuthMessage state (fun s i -> { s with UserInfo = i }) (fun s -> s.UserInfo)
We could also provide a "magic" macro, somewhat similar to Lens, that would allow passing this:
Lens
|> Action.MagicMap AuthMessage state.UserInfo
and would expand to the same as above:
|> Action.Map AuthMessage state (fun s i -> { s with UserInfo = i }) (fun s -> s.UserInfo)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
We need a function to wrap an action from a child update in a parent update, see https://forums.websharper.com/topic/87100:
We could also provide a "magic" macro, somewhat similar to
Lens
, that would allow passing this:|> Action.MagicMap AuthMessage state.UserInfo
and would expand to the same as above:
The text was updated successfully, but these errors were encountered: