Skip to content

Instantly share code, notes, and snippets.

@cboden
Created June 23, 2015 14:42
Show Gist options
  • Save cboden/0d21983e82ab0fb26c20 to your computer and use it in GitHub Desktop.
Save cboden/0d21983e82ab0fb26c20 to your computer and use it in GitHub Desktop.
Operator Subject
var sub = new Rx.Subject();
var obs = sub.distinctUntilChanged(); // This is what I want
function module1(sub) {
sub.subscribe(console.log.bind(console));
sub.onNext('hello');
}
function module2(sub) {
obs.subscribe(console.debug.bind(console));
sub.onNext('hello');
}
module1(sub);
module2(sub);
// I'd like to pass a subject to various modules that will publish and subscribe but I want operators applied before the subject is passed to the module so that when the module subscribes the operators are already applied.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment