Skip to content

Instantly share code, notes, and snippets.

@mfikes
Created April 21, 2015 21:13
Show Gist options
  • Save mfikes/ca2f1652f6830196f8e8 to your computer and use it in GitHub Desktop.
Save mfikes/ca2f1652f6830196f8e8 to your computer and use it in GitHub Desktop.
Smaller
cljs = {};
cljs.core = {};
cljs.core._deref = function cljs$core$_deref(o) {
if (o.cljs$core$IDeref$_deref$arity$1 != undefined) {
return o.cljs$core$IDeref$_deref$arity$1(o);
} else {
throw Error(["No protocol method IDeref defined for type :", o].join(""));
}
};
cljs.core.Volatile = function(state) {
this.state = state;
};
cljs.core.Volatile.prototype.cljs$core$IVolatile$_vreset_BANG_$arity$2 = function(_, new_state) {
var self__ = this;
return self__.state = new_state;
}; // this function is never called, yet deleting results in correct behavior
cljs.core.Volatile.prototype.cljs$core$IDeref$_deref$arity$1 = function(_) {
var self__ = this;
return self__.state;
};
print(function() {
var v = new cljs.core.Volatile(1);
return cljs.core._deref.call(null, v);
}());
cljs.core_test = {};
cljs.core_test.MyCustomAtom = function(state) {
this.state = state;
};
cljs.core_test.MyCustomAtom.prototype.cljs$core$IDeref$_deref$arity$1 = function(_) {
var self__ = this;
return self__.state;
};
print(function() {
var customAtom = new cljs.core_test.MyCustomAtom(10);
return cljs.core._deref.call(null, customAtom);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment