Skip to content

Instantly share code, notes, and snippets.

@dylanmcdiarmid
Created November 19, 2013 15:16
Show Gist options
  • Save dylanmcdiarmid/7546859 to your computer and use it in GitHub Desktop.
Save dylanmcdiarmid/7546859 to your computer and use it in GitHub Desktop.
Iced Coffee Script client side usage. This sets `iced` up as a global so your await/defer statements can work in the browser. I ripped this from the server side code, so it may not be entirely correct, but I do have it running and working in production.
window.iced = {
Deferrals: (function() {
__slice = [].slice
function _Class(_arg) {
this.continuation = _arg;
this.count = 1;
this.ret = null;
}
_Class.prototype._fulfill = function() {
if (!--this.count) return this.continuation(this.ret);
};
_Class.prototype.defer = function(defer_params) {
var _this = this;
++this.count;
return function() {
var inner_params, _ref;
inner_params = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (defer_params != null) {
if ((_ref = defer_params.assign_fn) != null) {
_ref.apply(null, inner_params);
}
}
return _this._fulfill();
};
};
return _Class;
})(),
findDeferral: function() {
return null;
},
trampoline: function(_fn) {
return _fn();
}
};
@red010182
Copy link

my broser (chorme v39) cannot recognize keyword "await"

@linus-amg
Copy link

wow awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment