On Tuesday, May 23, 2017 at 3:30:44 PM UTC+1, Christophe de Vienne wrote:
>
> It is what I did at first, but it has serious drawbacks. The biggest was 
> that a subscription implies an update of the Nats state... so I had to 
> push the state to all the update functions and they had to sent it 
> back... Very messy. 
>

This use case can be catered for by using a correlation id, I think. Also, 
perhaps the word 'subscription' is getting overloaded here, you have the 
Elm Sub(scription), and the NATS protocol subscription, and the middleware 
subscription (listen), making this conversation a little difficult to nail 
down...

== Module Consuming the NATS Protocol

Elmq.sendString "subscribe" "nats0"
Elmq.listen "nats0"

== The module implementing the NATS protocol

type Msg =
    NewNatsSubscription String
    | ...

Elmq.listenString "subscribe" (\channel -> NewNatsSubscription)
Elm.send channelName ...

==

So I sent a subscription request to Nats, and when Nats processed it, it 
sends back messages on the named channel. The channel name is used as a 
correlation id to link together the act of creating the subscription and 
the messages that then flow over that subscription.

I don't know the specific of NATS and whether it has named channels etc. 
but hopefully you get what I am on about?

-- 
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.

Reply via email to