我想在订阅中调整窗口大小时触发多条消息。
就像是:
subscription : Model -> Sub Msg
subscription model =
Window.resizes (\{width, height} ->
Sidebar "hide"
Layout "card"
Search <| Name ""
Screen width height
)
我如何同时激活它们?
最佳答案
虽然我没有说在手头的情况下这样做是件好事(逻辑应该驻留在 update
函数中),但您可以通过批处理这样的信号列表来做到这一点:
subscription : Model -> Sub Msg
subscription model =
Sub.batch
[ Window.resizes (\_ -> Sidebar "hide")
, Window.resizes (\_ -> Layout "card")
, Window.resizes (\_ -> Search <| Name "")
, Window.resizes (\{width, height} -> Screen width height)
]
见 this !
关于elm - 如何在 Elm 0.18 中的一个函数中触发多条消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42049090/