Created
June 23, 2015 14:42
-
-
Save cboden/0d21983e82ab0fb26c20 to your computer and use it in GitHub Desktop.
Operator Subject
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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