Skip to content

Introduce **> syntax#223

Closed
armanbilge wants to merge 3 commits intomainfrom
pr/i202
Closed

Introduce **> syntax#223
armanbilge wants to merge 3 commits intomainfrom
pr/i202

Conversation

@armanbilge
Copy link
Copy Markdown
Owner

@armanbilge armanbilge commented Mar 11, 2023

Closes #202.

Now you can write onFoo **> effect to evaluate an effect every time an event is emitted. The syntax is inspired by Cats *> aka productR i.e. a flatMap that ignores the result of the left-side.

I worry that this syntax obfuscates an important detail, that is clearer when working with a stream with the --> syntax. Specifically, that until effect completes, handling of additional events will be blocked. So effect should not be a long-running task; instead, long-running tasks should be scheduled on some Supervisor.

Of course, to avoid this surprise, we could have **> always run effect on its own fiber to avoid blocking handling of additional events. I'd prefer not to do this by default, because:

  1. the overhead of starting a fiber for each effect
  2. the overhead of setting up a Supervisor for each **>
  3. it makes it easy to start an unbounded number of tasks. In general, long-running tasks should be carefully managed, and requiring the user to set up a Supervisor or similar makes that management explicit.

Thoughts? :)

@armanbilge
Copy link
Copy Markdown
Owner Author

armanbilge commented Dec 4, 2024

@armanbilge armanbilge closed this Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

onClick --> { _.foreach { _ => ... } } is burdensome

1 participant