How to handle multiple subscriptions in the elm architecture

2.8k Views Asked by At

I am working through the elm guide.

In the effects subchapter there is an example with a Time-subscription

subscriptions : Model -> Sub Msg
subscriptions model =
  Time.every second Tick

and an example which handles Web-Sockets-subscriptions

subscriptions : Model -> Sub Msg
subscriptions model =
  WebSocket.listen "ws://echo.websocket.org" NewMessage

But in these examples, there is only ever one subscription. How could I handle multiple subscriptions?

1

There are 1 best solutions below

0
On BEST ANSWER

You may use Sub.batch, providing a list of subscriptions, it returns a batched subscription

Reference: