Skip to content

Instantly share code, notes, and snippets.

@peteruithoven
Last active September 9, 2016 12:54
Show Gist options
  • Save peteruithoven/e8833d2c0e336d1d55532216534bc3c8 to your computer and use it in GitHub Desktop.
Save peteruithoven/e8833d2c0e336d1d55532216534bc3c8 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!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>
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)
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"rxjs": "5.0.0-beta.11"
}
}
'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