gpt4 book ai didi

f# - Elmish.WPF 中子模型到父模型/主模型的消息传递是如何完成的?

转载 作者:行者123 更新时间:2023-12-02 19:06:25 25 4
gpt4 key购买 nike

(新手问题)。

在 Elmish.WPF 中,我有一个父模块 App,包含一个子子模块 FinderLastName:

module App =

type Model =
{
FinderLastName: FinderLastName.Model
}

type Msg =
| FinderLastNameMsg of FinderLastName.Msg


let update msg m =
match msg with
| FinderLastNameMsg msg ->
{ m with FinderLastName = FinderLastName.update msg m.FinderLastName}

let bindings () : Binding<Model, Msg> list = [
"FinderLastName" |> Binding.subModel(
(fun m -> m.FinderLastName),
snd,
FinderLastNameMsg,
FinderLastName.bindings)
]

子模型 FinderLastName 接收来自 UI 的文本输入,我需要将其传输到主应用程序模块。

假设子模型 FinderLastName 具有模型、消息和更新的典型 Elmish.WPF 结构,如何将文本输入从子/子模型传输到父/主模型?

(我发现了有关 Elm-spa 的很好的讨论,但是如何在 Elmish.WPF 中使用它? https://discourse.elm-lang.org/t/modifying-parent-state-from-child-page-in-an-elm-spa-example-like-architecture/2437 )

任何想法将不胜感激。

TIA

找到了!请参阅非常好的博客: https://medium.com/@MangelMaxime/my-tips-for-working-with-elmish-ab8d193d52fd

大约往下3/4,让 child 与家长沟通

附录:有关 Elmish 使用的事件循环的详细解释,请参阅:https://elmish.github.io/elmish/

最佳答案

OP共享this Elm discussionthis comment 。正如我在 this comment 中所说,我喜欢那里提到的翻译模式。我计划很快在 Elmish.WPF 中实现它。

关于f# - Elmish.WPF 中子模型到父模型/主模型的消息传递是如何完成的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64998508/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com