kefirjs / kefir

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

Creating stream for reading file using fromNodeCallback #83

Closed ospatil closed 9 years ago

ospatil commented 9 years ago

I'm trying to create a stream to read file contents using fs.readFile. In BaconJS, I can achieve this by -

var readStream = Bacon.fromNodeCallback(fs.readFile, 'somefile.txt');

readStream.onValue(function (data) {
    //do something with data
});

I have checked API and specs but I see Kefir.fromNodeCallback only accepts single function as argument. Am I missing something obvious? How can I achieve this in Kefir?

rpominov commented 9 years ago

You can use .bind like this: Kefir.fromNodeCallback(fs.readFile.bind(fs, 'somefile.txt'))