made with esnextbin
Last active
September 9, 2016 12:54
-
-
Save peteruithoven/e8833d2c0e336d1d55532216534bc3c8 to your computer and use it in GitHub Desktop.
esnextbin sketch
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
</body> | |
</html> |
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
import {BehaviorSubject } from 'rxjs/BehaviorSubject'; | |
var subject = new BehaviorSubject(); | |
subject.next('some first value'); | |
subject.next('before subscription'); | |
subject.subscribe(function(val) { | |
console.log('early listener updated: ', val) | |
}); | |
subject.next('after subscription'); | |
setTimeout(() => { | |
// This subscription still receives 'after subscription', | |
// even though he wasn't listening yet | |
subject.subscribe(function(val) { | |
console.log('delayed listener updated: ', val) | |
}); | |
subject.next('after delayed subscription'); | |
}, 1000) |
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
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"rxjs": "5.0.0-beta.11" | |
} | |
} |
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
'use strict'; | |
var _BehaviorSubject = require('rxjs/BehaviorSubject'); | |
var subject = new _BehaviorSubject.BehaviorSubject(); | |
subject.next('some first value'); | |
subject.next('before subscription'); | |
subject.subscribe(function (val) { | |
console.log('early listener updated: ', val); | |
}); | |
subject.next('after subscription'); | |
setTimeout(function () { | |
// This subscription still receives 'after subscription', | |
// even though he wasn't listening yet | |
subject.subscribe(function (val) { | |
console.log('delayed listener updated: ', val); | |
}); | |
subject.next('after delayed subscription'); | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment