Skip to content

Instantly share code, notes, and snippets.

@getify getify/1.js

Last active Sep 19, 2019
What would you like to do?
quick sketch of CAF
send = CAF(send);
var prevSend = Promise.resolve();
function onSend(evt) {
prevSend.finally(function f(){
prevSend = send(
CAF.timeout(1000,"send took too long."),
{ some: "data" }
function *send(signal,data){
var res = yield fetch("/some/url",{
body: JSON.stringify(data),
if (res.ok) {
let resp = yield res.text(); // note: this call doesn't need a Promise.race() because CAF does it for you
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.