Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.