-
Notifications
You must be signed in to change notification settings - Fork 42
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
WIP: Introduce generalized abstraction over streams #571
base: master
Are you sure you want to change the base?
Conversation
Turns out I just found a way to get rid of the wrappers and the Env class as well. It just requires some fiddling inside sbt. |
That whole topic sounds super interesting! Do you have a small code example of usage that you could share? |
@fdietze The goal here is to make outwatch use any streaming libraries types internally and expose those in every function.
|
Thank you for the detailed description! This is impressive. 👍 Would all outwatch artifacts still be fully colibri compatible? |
No. Only the |
This Pull Request aims to introduce a generalized abstraction over streams to outwatch via use of the hummingbird library. While this PR is still a work in progress, it could in theory make outwatch compatible with libraries such as zio and fs2 without the need to introduce their specific features into outwatch itself.
The concept works as if the entire library was wrapped into a trait that defines two abstract type parameters,
Rx[-T]
andTx[+T]
. These take the role of theObserver
and theObservable
respectively. The usual set of streaming functions is made available for these types via syntax imports. When working with a specific streaming library, the trait is extended and the abstract types are set to whichever streaming types are supported, i.e.fs2.Stream
orzio.ZStream
and so on.While this example is nice to visualize the concept, in reality it is a bit more complicated since the concept would require us to write all of the libraries code into a singe file. Instead this PR creates a class called
Env
which provides the necessary environment everything is wrapped into it individually.From a user perspective, this would require changing all imports to something along the lines of
import outwatch.ext.monix.dsl._
, which would provide a version of the library with all types set to monix ones.Even though I am still not done integrating this, I wanted to make this PR to get some feedback on the general idea.
I also expect scala 3 to make this concept a bit more usable, since a lot of the namespace crazyness can probably be avoided using
export
, trait parameters,opaque
types and more.Right now this requires the hummingbird library to be checked out into the parent folder of this repo, which makes it easier to develop on both libraries at once as opposed to using jitpack.
btw, I do not expect this to get merged as is, since I am wrapping every single file in outwatch in an entire class, which feels pretty insane, I don't like it. I just wanted to see where this concept takes me and this is where I wound up. I hope that I can find a way to manage this entirely via imports, but I don't know if that's possible so I have to ask around more on the scala channels first.