Open RoyalIcing opened 3 years ago
const machine = start(Machine); const eventSource = new EventSource(); machine.receiveFrom(eventSource); const messagesKey = Symbol("messages"); function* Machine() { yield listenTo(eventSource, "open"); yield on(new Map([["type", "error"], ["readyState", EventSource.CLOSED]]), Closed); function* Open() { yield listenTo(eventSource, "message"); yield accumulate("message", messagesKey); } function* Closed() {} return function* Initial() { yield listenTo(eventSource, "open"); yield on("open", Open); } }
This is implemented. It does seem to run in an infinite loop, re-opening after it closes.