made with esnextbin
Last active
August 12, 2016 18:01
-
-
Save tusharmath/feed4f6534ae20c78d74afa052d2976d 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
// 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)) |
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", | |
"dependencies": { | |
"rx": "2.3.0" | |
}, | |
"version": "0.0.0" | |
} |
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 _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