(新手问题)。
在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)
]subModel,FinderLastName,接收来自UI的文本输入,我需要将其传输到主应用程序模块。
假设subModel、FinderLastName具有典型的模型、Msg和update的Elmish.WPF结构,如何将文本输入从子/子模型传输到父/主模型?
(我发现对榆树温泉有很好的讨论,但如何在Elmish.WPF?https://discourse.elm-lang.org/t/modifying-parent-state-from-child-page-in-an-elm-spa-example-like-architecture/2437中使用?)
任何想法都将不胜感激。
提亚
找到了!请看真正好的博客: https://medium.com/@MangelMaxime/my-tips-for-working-with-elmish-ab8d193d52fd
约3/4的方式下,使孩子与父沟通
增编:有关Elmish使用的事件循环的详细说明,请参阅:https://elmish.github.io/elmish/
发布于 2020-11-26 02:06:58
发布于 2020-11-25 11:34:20
Elmish.WPF回购中构建了几个很好的示例项目,它们演示了这类东西。看看名字中有"SubModel“的项目。
我建议您克隆回购并在IDE中打开它,以获得完整的类型推断。您还可以运行每个示例项目。我个人认为这是一种很好的文档形式。
https://stackoverflow.com/questions/64998508
复制相似问题