-
-
Notifications
You must be signed in to change notification settings - Fork 420
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
feat(): use adapters #198
feat(): use adapters #198
Conversation
Uses an adapter interface to allow for cycle-core to adapt to any and all stream/observable libraries that have an adapter written. This branch uses an Rx 4 adapter for the tests.
👍 Very clever. Code of my own heart. I look forward testing this out. 👍 again! |
With this cycle-core can be entirely stream/observable library agnostic via adapters. import Cycle from '@cycle/core'
import streamAdapter from 'cycle-rx-adapter'
...code here....
run(main, driver, {streamAdapter}) A driver that is not written in the library that the streamAdapater you chose to give to function driverFn(sink$) {...}
driverFn.streamAdapter = rxAdapter // mostAdapter |
👍 for the adapter solution in general. About the API: import Rx from 'rx'
run(main, driver, {streamLibrary: Rx}) would be better. In fact, we can assume Rx as the default library. So then we can change package.json -"cycle-rx-adapter": "^0.2.0",
"rx": "4.0.7", It'd make more sense for most Cycle developers to install Also, in the streams adapter code, I suppose |
I'm getting ready for sleep, so I'll have to try to get a better reply later, but personally I have no plans to ever use Rx. I plan to use Most only, and I don't want to have Rx in my code base if it's not required. That would be required with what you propose. My goals with this is to allow cycle-core to become a single place for both visions (and more) to exist. It's fair to say I'm probably on the outside looking in there. It's also possible to wrap this up in other libraries with default adapters if that is desired. npm install @cycle/rx @cycle/dom
npm install @cycle/most @cycle/dom
npm install @cycle/whatever @cycle/dom At the end of the day, this isn't my library though. |
Oh yeah, forgot the timezone issues! |
Been up about 27 hours haha |
Ok, that affects only this:
How bad would it be to publish packages
To replace the |
Maybe that's what you meant with |
And again I'm caught thinking of bundling the stream library inside |
import Cycle from '@cycle/core'
import streamAdapter from 'cycle-rx-adapter'
const cycle = {
run: (main, drivers) => Cycle.run(main, drivers, {streamAdapter})
}
export default cycle |
this does seem the most intuitive to me |
In that case we could rename |
Should 'officially' supported adapters exist within |
Other than that, I find naming to be trivial. |
Yeah I think |
If we rename |
Good point. We can do the alias |
That sounds appropriate. 👍 |
We can also alias |
I'm inclined to suggest Loose list of things to do in no particular order
Anything else? Should we move motorcycle-dom to |
Everything correct. And one thing just to be sure: add test on |
Updated |
Injects adapt function for drivers with complex APIS that need to do manual stream adaptation. e.g. DOM driver
}) | ||
return sinks | ||
} | ||
const adapt = stream => // eslint-disable-line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const streamAdaptation = ...
By same logic, @cycle/dom should also then be default, because using it is going to be far more common than "I want to use Cycle with my own non-officially-supported DOM library". The problem I see with Rx as default is that Rx will be included in my app code whether I use it or not. In my view, if you want to provide users with a default setup, just make a new repo/package that has the necessary dependencies and imports to your liking. This will leave other repo/packages separated with their respective concerns. (I hear the crowd cheering for separation of concerns and the flexibility it provides). |
@Frikki that comment was "deprecated". Remove the last sentence: Because "just using Cycle with Rx" is going to be far more common
than "I want to use Cycle with my own non-officially-supported streams
library", an API like ... would be better.
-In fact, we can assume Rx as the default library. |
@staltz Okay. Is the Rx dependency solved then? And how? I find it a bit difficult to follow the above discussion. UPDATE |
It is solved... I updated issue #196 summarizing our solution. |
Closing this as we're moving this PR to base |
Uses an adapter interface to allow for cycle-core to adapt
to any and all stream/observable libraries that have an adapter
written. This branch uses an Rx 4 adapter for the tests.