made with esnextbin
Created
May 30, 2017 23:29
-
-
Save trxcllnt/e4ac21c792239bc0a0b1573d4ba2ee16 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains hidden or 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 hidden or 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 { Observable } from 'rxjs'; | |
import { Model } from '@graphistry/falcor'; | |
const modelGet = Model.prototype.get; | |
Model.prototype.get = function getAsObs(...paths) { | |
return Observable.from(modelGet.apply(this, paths)); | |
} | |
const model = new Model({ | |
recycleJSON: true, | |
cache: { | |
foo: { val: 'foo-val' }, | |
bar: { val: 'bar-val' } | |
} | |
}); | |
const fooModel = model._clone({_seed: {}}); | |
const barModel = model._clone({_seed: {}}); | |
fooModel | |
.get(['foo', 'val']) | |
.delay(100) | |
.subscribe(logResult('foo.val:')); | |
barModel | |
.get(['bar', 'val']) | |
.delay(100) | |
.subscribe(logResult('bar.val:')); | |
function logResult(prefix) { | |
return function({ json }) { | |
console.log(prefix, JSON.stringify(json)); | |
} | |
} |
This file contains hidden or 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": { | |
"babel-runtime": "6.23.0", | |
"@graphistry/falcor": "2.9.3", | |
"rxjs": "5.4.0" | |
} | |
} |
This file contains hidden or 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 _stringify = require('babel-runtime/core-js/json/stringify'); | |
var _stringify2 = _interopRequireDefault(_stringify); | |
var _rxjs = require('rxjs'); | |
var _falcor = require('@graphistry/falcor'); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
var modelGet = _falcor.Model.prototype.get; | |
_falcor.Model.prototype.get = function getAsObs() { | |
for (var _len = arguments.length, paths = Array(_len), _key = 0; _key < _len; _key++) { | |
paths[_key] = arguments[_key]; | |
} | |
return _rxjs.Observable.from(modelGet.apply(this, paths)); | |
}; | |
var model = new _falcor.Model({ | |
recycleJSON: true, | |
cache: { | |
foo: { val: 'foo-val' }, | |
bar: { val: 'bar-val' } | |
} | |
}); | |
var fooModel = model._clone({ _seed: {} }); | |
var barModel = model._clone({ _seed: {} }); | |
fooModel.get(['foo', 'val']).delay(100).subscribe(logResult('foo.val:')); | |
barModel.get(['bar', 'val']).delay(100).subscribe(logResult('bar.val:')); | |
function logResult(prefix) { | |
return function (_ref) { | |
var json = _ref.json; | |
console.log(prefix, (0, _stringify2.default)(json)); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment