[RxJS] Convert a Node.js style callback to Observable: bindNodeCallback

It's just like bindCallback, but the callback is expected to be of type callback(error, result).

import * as fs from 'fs';
const readFileAsObservable = bindNodeCallback(fs.readFile);
const result = readFileAsObservable('./roadNames.txt', 'utf8');
result.subscribe(x => console.log(x), e => console.error(e));

 

你可能感兴趣的:([RxJS] Convert a Node.js style callback to Observable: bindNodeCallback)