Created
October 18, 2015 06:02
-
-
Save bouzuya/af7e1b4f3d634a261042 to your computer and use it in GitHub Desktop.
scan とか reduce とかの検証用のゴミ
This file contains 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
Rx.Observable.create((observer) => { | |
setTimeout(() => { | |
observer.onNext(1000); | |
setTimeout(() => { | |
observer.onNext(3000); | |
setTimeout(() => { | |
observer.onCompleted(5000); | |
}, 2000); | |
}, 2000); | |
}, 1000); | |
return observer; | |
}) | |
.scan(((s, i) => s + i), 0) // reduce だと…… | |
.subscribe((i) => { | |
console.log('subscribe ' + i); | |
}); | |
Rx.Observable | |
.empty() | |
.scan((a, i) => console.log('empty' + i), []) | |
.subscribe((i) => { | |
console.log(i); | |
}); | |
Rx.Observable | |
.just([]) | |
.scan((a, i) => console.log('just' + i), []) | |
.subscribe((i) => { | |
console.log(i); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment