Effect CommunityEC
Effect Communityβ€’3y agoβ€’
55 replies
schniz

Effect Runtime

tried to look for it in the docs, api reference etc.
how would one use Effects in stuff like the DOM environment? things like so:
Effect.gen(function*($) {
// later, in a `Effect.sync` or something
document.addEventListener("click", event => {
  // I can construct a new `Effect` here,
  // but I'll have to `.runSync` it.
})
})

Once I use Effect.runSync or other functions like it, it means I'm detaching this Effect from the layers, right? Is there a nice way of maintaining this connection and not have "islands" of Effects everywhere?
I also thought about using @effect/stream but unfortunately event handlers must be synchronous for propagation to work correctly (afaik) πŸ€”
Was this page helpful?