Reputation: 2759
I am trying to capture Server Events in Elm. But I couldn't found a library. Or I don't know default http library can do this.
Here is JavaScript code I wanted to write in Elm.
var source = new EventSource(
'/event-stream?channel=channel&t=' + new Date().getTime());
There is obvious work around is I write JS code and port in Elm application. But I guess that will pollute the code. If I can have both in Elm, and possible I can join in Stream/Signal application would become fully reactive to Server. That is the end goal.
Please let me know if any further details are required.
PS: Above code is basic Html5 code.
Upvotes: 4
Views: 425
Reputation: 1207
As of Elm 0.16, pushing values from the event stream in through a port is the best option for this. There's no way to access and instantiate an EventSource
within Elm code.
Upvotes: 3