calmm-js / karet

Karet is a library that allows you to embed Kefir observables into React VDOM
MIT License
83 stars 8 forks source link

Accept ES7 Observables instead of Kefir #17

Open fiatjaf opened 7 years ago

fiatjaf commented 7 years ago

I know this library is specially modelled for Kefir streams, hence its name, but I think it would be great if any reactive streams library could be used (I personally like https://github.com/staltz/xstream, although Kefir looks great for my use-case), maybe using a different name and a different repository.

I've come up with the following changes: https://github.com/calmm-js/karet/compare/master...fiatjaf:b460d77fa8b38188e8003dc3de90bf161dc89d67

But they don't pass the tests (I've used xstream on the tests instead of Kefir), so I'm looking for help.

fiatjaf commented 7 years ago

I think I got it right here: https://github.com/fiatjaf/oaret

polytypic commented 7 years ago

I took a very quick look and it seems roughly right. 👍 There might be some corner cases to consider due to Kefir (and Bacon) having different semantics from those of ES7 observables in case of errors.

IIRC, @rikutiira was also interested in an ES7 observable port.

I noticed that you didn't port fromKaret? That is actually very nice to have every now and then. So I'd recommend porting it, too.

Also, you switched to using legacy CommonJS modules. Note that having the ES2015 style modules and a module entry point in package.json helps modern bundlers and UglifyJS to do a better job at dead code elimination. In fact, with Rollup, ES2015 modules, UglifyJS /*#__PURE__*/ annotations and FP style code, dead code elimination can be very effective.

BTW, did you notice the Gitter room?

fiatjaf commented 7 years ago

I tried to keep the whole boilerplate, but I gave up when nyc (I guess it was this thing) started crashing my computer and leaving hanging processes whenever I ran the tests.

I also don't like the idea of having to compile the code before running the tests. I know you're right about ES modules and Rollup, since I recently read on that topic and got convinced, but I did what I did on a burst of irrational rage against nyc and babel.

In the long run I think I will bring back some things I've just deleted, yes, but now I just want to build the project I left hanging for a month while I searched for a library like karet (which I didn't know if existed).