Skip to content

Instantly share code, notes, and snippets.

@mickvangelderen
Last active March 29, 2016 10:58
Show Gist options
  • Save mickvangelderen/8463e8483667807250e6 to your computer and use it in GitHub Desktop.
Save mickvangelderen/8463e8483667807250e6 to your computer and use it in GitHub Desktop.
function Future$fork(rej, res){
check$fork(this, rej, res);
let immediate = false;
let clear = function Future$fork$immediateClear() {
immediate = true
};
const _this = this;
function maybeClear() {
if (_this._b && clear) {
clear()
clear = null
}
}
clear = fork(this, function Future$fork$rej(x){
maybeClear();
rej(x);
}, function Future$fork$res(x){
maybeClear();
res(x);
});
if (immediate) maybeClear();
return clear;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment