recyclejs / recycle

Convert functional/reactive object description using RxJS into React component

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why you removed adapters?

goodmind opened this issue · comments

So, how to use this library with different streams. I come from cycle.js and this is really killer-feature for me as well as better effects handling (drivers)

@goodmind
concept with drivers from previous version was a very complex one. I was basically recreating how React works, dealing with all kinds of problems (determining which component should be updated on rerendering, keeping track of element keys for preserving component state and similar).

Also, while building apps with drivers, I always ended up using just two "main" streams: state and actions (which is why Redux is supported).
For side effects I would just listen on component dispatched actions and use redux-observable or similar.

However, you can still use any stream you want, but it's up to you to "wire them up". You can, for example, pass them as params inside a factory function or similar.

But you can use

Symbol.observable

to return ES compatible observable with subscribe method

I see subscribe used in component.js so I don't need to reimplement it for every stream library

I thought you were referring to drivers for handling side-effects by providing streams to every component.

But that is another issue, I now see what you mean.

I plan to support other stream libraries by using redux observable concept, but I'm not sure yet. I will consider your proposal with Symbol.observable as well.

Also, if you wish, feel free to send your PR for this.

Well, I tried to do something with different streams and it looks like it even works without interop:

import Rx from 'rxjs'
import xs from 'xstream'

Rx.Observable.merge(xs.of(1), xs.of(2)).subscribe(console.log) 
/*
  1
  2
*/

But, I'm didn't try to do this with recycle