Skip to content

Instantly share code, notes, and snippets.

@tuan
Created May 9, 2017 23:08
Show Gist options
  • Save tuan/2c6c8c70291f0aef7d790ec478c9b035 to your computer and use it in GitHub Desktop.
Save tuan/2c6c8c70291f0aef7d790ec478c9b035 to your computer and use it in GitHub Desktop.
RxJS bindcallback's stream completes after first emit
// jsbin https://jsbin.com/xeyugac/edit?js,console
const { Observable } = Rx;
const testFn = (callback) => {
callback(1,2);
};
const testFnAsObservable = Observable.bindCallback(testFn);
const obs = testFnAsObservable();
obs.subscribe(
value => console.log('value', value),
error => console.error(error),
() => console.log('complete!')
);
// output
// value [1,2]
// complete!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment