Skip to content

Instantly share code, notes, and snippets.

@tusharmath
Last active August 12, 2016 18:01
Show Gist options
  • Save tusharmath/feed4f6534ae20c78d74afa052d2976d to your computer and use it in GitHub Desktop.
Save tusharmath/feed4f6534ae20c78d74afa052d2976d 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>
// write ES2015 code and import modules from npm
// and then press "Execute" to run your program
import {Observable as O} from 'rx'
function RAFThrottle(source) {
var canUpdate = true;
return source
.filter(e => canUpdate)
.do(e => {
canUpdate = false;
requestAnimationFrame(() => canUpdate = true);
});
}
const t= O.interval(1).take(10)
const r = RAFThrottle(t)
r.subscribe(x => document.writeln('A', x))
r.subscribe(x => document.writeln('B', x))
{
"name": "esnextbin-sketch",
"dependencies": {
"rx": "2.3.0"
},
"version": "0.0.0"
}
'use strict';
var _rx = require('rx');
function RAFThrottle(source) {
var canUpdate = true;
return source.filter(function (e) {
return canUpdate;
}).do(function (e) {
canUpdate = false;
requestAnimationFrame(function () {
return canUpdate = true;
});
});
} // write ES2015 code and import modules from npm
// and then press "Execute" to run your program
var t = _rx.Observable.interval(1).take(10);
var r = RAFThrottle(t);
r.subscribe(function (x) {
return document.writeln('A', x);
});
r.subscribe(function (x) {
return document.writeln('B', x);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment