I think what you have in your first post is just fine. The combineSubscriptions seems like overkill for a two-item list.
If it bugs you to have to pass the model to a bunch of different functions, I'm curious how complicated the "viewSubscriptions" and "webSubscriptions" functions are, and whether it would make more sense to pull them up into your main module. In particular... the Elm "view" function is just the HTML output, so putting Keyboard subscriptions in a module called "View" doesn't seem necessary. Of course I don't know anything else about your program, so this is just me thinking out loud :) On Tue, Dec 20, 2016 at 12:46 PM, Marshall handheld Flax < [email protected]> wrote: > Thinking about this a little more...should the Sub module just have > something like the following? > > combineSubscriptions : List (m -> Sub msg) -> (m -> Sub msg) > combineSubscriptions list model = > Sub.batch (List.map ((|>) model) list) > > Thanks again! > > Marshall > > > On Tuesday, December 20, 2016 at 1:39:43 PM UTC-5, Marshall handheld Flax > wrote: >> >> My main program has two types of subscriptions: UI subscriptions (e.g. on >> Keyboard.downs) defined in my View.elm, and Websocket.Listen subscriptions >> defined in my State.elm. But to batch them together, I need to create an >> anonymous function to factor the model through. Is this idiomatic or is >> there a better way? >> >> Thank you!!! >> >> Marshall >> >> main = >> Html.program >> { init = State.init >> , update = State.update >> , view = View.root >> , subscriptions = \model -> Sub.batch [ View.viewSubscriptions >> model, State.webSubscriptions model ] >> } >> >> >> -- > You received this message because you are subscribed to the Google Groups > "Elm Discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
