>
> Yes, that is perfect for my use case, thanks. This should be added to the 
> official packages?
>
 
This kind of messaging is not encouraged (sending things around the 
program), so It probably will not be added to the official packages.

That is, I provide the name of the channel and it returns a send/listen 
> pair that operate on type 'a'. Or perhaps it is just:
>
> send : String -> a -> Cmd msg
> listen : String -> (a -> msg) -> Sub msg
>
> Is there some reason this cannot be done?
>

I tried to implement that with pure Elm but the way effect managers works 
prevents that.
It can be done with some native functions, but it's dangerous because 
prevents type checking (it directly feeds the given messages back into the 
program).


On Tuesday, November 22, 2016 at 11:17:05 AM UTC+1, Rupert Smith wrote:
>
> On Tuesday, November 22, 2016 at 4:59:22 AM UTC, Gusztáv Szikszai wrote:
>>
>> I think you are looking for something like this: 
>> https://github.com/gdotdesign/elm-ui/blob/master/source/Ui/Helpers/Emitter.elm
>>  
>> It's a pure Elm pub / sub effects module (and possibly the most minimal 
>> example of an effect module).
>>
>
> Yes, that is perfect for my use case, thanks. This should be added to the 
> official packages?
>
> I was wondering, would it be possible to make a send/listen pair where the 
> type of the item being transmitted is variable? For example, the 
> send/listen pair for a Json Value is:
>
> send : String -> Value -> Cmd msg
> listen : String -> (Value -> msg) -> Sub msg
>
> But given there is no native code at all, why translate to json? It seems 
> unnecessary. Instead I want a constructor for the send/listen pair:
>
> mailbox : String -> (a -> Cmd msg, (a -> msg) -> Sub msg)
>
> That is, I provide the name of the channel and it returns a send/listen 
> pair that operate on type 'a'. Or perhaps it is just:
>
> send : String -> a -> Cmd msg
> listen : String -> (a -> msg) -> Sub msg
>
> Is there some reason this cannot be done?
>
>

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