-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ZIO / FS2 / etc. integration examples #140
Comments
Self-aggrandized snake-oil coming up, sorry 😁 If you want to take this idea to the extreme: the main motivation for Calico is to answer the question, what if we built Laminar (or something Laminar-like, anyway) from the ground up with effects? (It is effect-agnostic, so it can work with effect types other than Cats Effect |
(Random comment: this will work with ZIO 2.x. You need to adapt the |
Question just out of interes: would it theoretically be possible to rewrite Laminar using ZIO or cats-effect - or is that not possible due to things like "No FRP Glitches" or other aspects in how the effect systems differ? |
@valentin-panalyt Laminar only uses Airstream as a reactive layer. The underlying DOM operations work on low level observable-agnostic callbacks. So, yes, in principle you can make a similar library with IO and ZIO instead of Airstream. And if you actually want Laminar-like observable API, you might want to use a streaming library, not an effect tracking library. So, more like FS2 / ZIO streams I guess. Either way, you will have to deal with various kinds of friction like FRP glitches because those libraries are designed for use in concurrent backend systems, and make different design decisions with different tradeoffs. You might be interested to see how Tyrian and Calico are made, they both are FP-centric designs. |
We have actually gotten much closer to this now! Laminar and FS2 can now be integrated like this, without needing any other adapter library. import cats.effect.unsafe.implicits._ // imports implicit IORuntime
EventStream.fromPublisher(fs2Stream.unsafeToPublisher()) |
Laminar does not and will not have built-in integrations with ZIO / FS2 / etc., but anyone who actually uses these libraries on the frontend can easily publish their own packages or even just share a gist. If you need help developing such a package, feel free to ask in our Discord – although I personally don't use ZIO / FS2 / etc. especially on the frontend, a few other people do.
I'm opening this ticket as a reference for any such integration examples until I have a more permanent place to put them. Please feel free to comment with more example code or links.
To start off, here is an example ZIO integration from @sherpal that he posted on discord:
and
The text was updated successfully, but these errors were encountered: