kefirjs / kefir

A Reactive Programming library for JavaScript
https://kefirjs.github.io/kefir/
MIT License
1.87k stars 97 forks source link

Custom builds / partial imports #84

Closed nstadigs closed 5 years ago

nstadigs commented 9 years ago

Hi! I've been playing around a bit with the transducer support lately (works great btw) and I've noticed that I don't really need any of the other stream modification methods anymore. It would be great to be able to opt out by using an optional dist build. This would make kefir a pretty "clean" observables layer in the application. I think that this feature could drive some adoption. Maybe something for the refactoring that is 2.0?

Thanks a lot for all your great work.

rpominov commented 9 years ago

Hi! I'am thinking of porting source to es6 using babel+webpack, there will be an entry .js file where all modules are required and the Kefir object is build. Then it will be easy to create your own entry .js file with transformation methods removed. This probably will happen after 2.0, as it not a breaking change, and I want to minimize work to be done for releasing 2.0.

nstadigs commented 9 years ago

That sounds like an even better solution, indeed!

rpominov commented 9 years ago

We now have https://github.com/rpominov/kefir/blob/master/src/index.js, and it should be easy to create such custom builds. You'll just need to comment out not needed parts in index.js and then run grunt.

I'm also thinking of making it possible to import just needed pieces when using kefir as NPM package. So one can do something like:

const stream = require('kefir/primary/stream');
const map = require('kefir/one-source/map');

let myStream = stream(emitter => {
  emitter.emit(1);
});

let mapped = map(myStream, x => x + 1);

mapped.onValue(x => console.log(x));
nstadigs commented 9 years ago

Great news! Thanks!

mAAdhaTTah commented 5 years ago

This looks like it has been solved, so closing.