Christophe de Vienne
2017-05-16 14:30:07 UTC
Hi everyone,
I am attempting to implement the pub/sub NATS (https://nats.io) protocol
on top of the WebSocket API as a TEA component.
I have a hard time finding an API for subscriptions: for each
subscription some context must be kept, a unique subscription ID
generated and in some case a unique reply subject too, and I would like
each subscription to generate custom messages for the component which
made it.
I suspect it would be a lot more natural with an effect module, with
which I could (hopefully) write, in any part of the application:
subscriptions : Model -> Sub Msg
subscriptions model =
Nats.Subscribe model.endpoint "some.subject" MyMessage
or, for req/rep (a pub + a short-living sub expecting a result):
myrequest : Model -> Cmd Msg
myrequest model =
Nats.request model.endpoint "a.request.subject" MyReply
Another difficulty I have is that in some cases I need to send 2 or 3
messages through the websocket, in the right order, but WebSocket.send
returns a Cmd. So I have to concat the 3 commands in 1 message, which
works but oblige
Am I wrong being tempted by using an effect module for this kind of module ?
If so how can I mimick such an API with a TEA approach ?
If not is there any documentation I can read to get familiar with them ?
Is there any existing module that does this kind of thing for another
protocol ?
Thanks!
I am attempting to implement the pub/sub NATS (https://nats.io) protocol
on top of the WebSocket API as a TEA component.
I have a hard time finding an API for subscriptions: for each
subscription some context must be kept, a unique subscription ID
generated and in some case a unique reply subject too, and I would like
each subscription to generate custom messages for the component which
made it.
I suspect it would be a lot more natural with an effect module, with
which I could (hopefully) write, in any part of the application:
subscriptions : Model -> Sub Msg
subscriptions model =
Nats.Subscribe model.endpoint "some.subject" MyMessage
or, for req/rep (a pub + a short-living sub expecting a result):
myrequest : Model -> Cmd Msg
myrequest model =
Nats.request model.endpoint "a.request.subject" MyReply
Another difficulty I have is that in some cases I need to send 2 or 3
messages through the websocket, in the right order, but WebSocket.send
returns a Cmd. So I have to concat the 3 commands in 1 message, which
works but oblige
Am I wrong being tempted by using an effect module for this kind of module ?
If so how can I mimick such an API with a TEA approach ?
If not is there any documentation I can read to get familiar with them ?
Is there any existing module that does this kind of thing for another
protocol ?
Thanks!
--
Christophe de Vienne
--
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 elm-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Christophe de Vienne
--
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 elm-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.