-
-
Save Bretto/67d3e2a0504ce06da0608795d90c7fce to your computer and use it in GitHub Desktop.
takeUntil
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
const click$ = Rx.Observable | |
.fromEvent(document, 'click'); | |
const four$ = Rx.Observable.interval(4000).take(1); | |
/* | |
click$ --c------c---c-c-----c---c---c- | |
four$ -----------------0| | |
clickUntilFour$ --c------c---c-c-| | |
*/ | |
const clickUntilFour$ = click$.takeUntil(four$); | |
clickUntilFour$.subscribe(function (ev) { | |
console.log(ev.clientX) || displayInPreview(ev.clientX); | |
}); | |
// display in plunker preview | |
function displayInPreview(string) { | |
var newDiv = document.createElement("div"); | |
var newContent = document.createTextNode(string); | |
newDiv.appendChild(newContent); | |
document.body.appendChild(newDiv) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment