1660 lines
61 KiB
JavaScript
1660 lines
61 KiB
JavaScript
goog.provide('reagent.ratom');
|
|
goog.scope(function(){
|
|
reagent.ratom.goog$module$goog$object = goog.module.get('goog.object');
|
|
});
|
|
if((typeof reagent !== 'undefined') && (typeof reagent.ratom !== 'undefined') && (typeof reagent.ratom.debug !== 'undefined')){
|
|
} else {
|
|
reagent.ratom.debug = false;
|
|
}
|
|
if((typeof reagent !== 'undefined') && (typeof reagent.ratom !== 'undefined') && (typeof reagent.ratom.generation !== 'undefined')){
|
|
} else {
|
|
reagent.ratom.generation = (0);
|
|
}
|
|
if((typeof reagent !== 'undefined') && (typeof reagent.ratom !== 'undefined') && (typeof reagent.ratom._running !== 'undefined')){
|
|
} else {
|
|
reagent.ratom._running = cljs.core.atom.cljs$core$IFn$_invoke$arity$1((0));
|
|
}
|
|
reagent.ratom.reactive_QMARK_ = (function reagent$ratom$reactive_QMARK_(){
|
|
return (!((reagent.ratom._STAR_ratom_context_STAR_ == null)));
|
|
});
|
|
reagent.ratom.running = (function reagent$ratom$running(){
|
|
return (cljs.core.deref(reagent.ratom._running));
|
|
});
|
|
reagent.ratom.arr_len = (function reagent$ratom$arr_len(x){
|
|
if((x == null)){
|
|
return (0);
|
|
} else {
|
|
return x.length;
|
|
}
|
|
});
|
|
reagent.ratom.arr_eq = (function reagent$ratom$arr_eq(x,y){
|
|
var len = reagent.ratom.arr_len(x);
|
|
var and__5023__auto__ = (len === reagent.ratom.arr_len(y));
|
|
if(and__5023__auto__){
|
|
var i = (0);
|
|
while(true){
|
|
var or__5025__auto__ = (i === len);
|
|
if(or__5025__auto__){
|
|
return or__5025__auto__;
|
|
} else {
|
|
if(((x[i]) === (y[i]))){
|
|
var G__51872 = (i + (1));
|
|
i = G__51872;
|
|
continue;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
} else {
|
|
return and__5023__auto__;
|
|
}
|
|
});
|
|
/**
|
|
* When f is executed, if (f) derefs any ratoms, they are then added to 'obj.captured'(*ratom-context*).
|
|
*
|
|
* See function notify-deref-watcher! to know how *ratom-context* is updated
|
|
*/
|
|
reagent.ratom.in_context = (function reagent$ratom$in_context(obj,f){
|
|
var _STAR_ratom_context_STAR__orig_val__51648 = reagent.ratom._STAR_ratom_context_STAR_;
|
|
var _STAR_ratom_context_STAR__temp_val__51649 = obj;
|
|
(reagent.ratom._STAR_ratom_context_STAR_ = _STAR_ratom_context_STAR__temp_val__51649);
|
|
|
|
try{return (f.cljs$core$IFn$_invoke$arity$0 ? f.cljs$core$IFn$_invoke$arity$0() : f.call(null));
|
|
}finally {(reagent.ratom._STAR_ratom_context_STAR_ = _STAR_ratom_context_STAR__orig_val__51648);
|
|
}});
|
|
/**
|
|
* Returns `(in-context r f)`. Calls `_update-watching` on r with any
|
|
* `deref`ed atoms captured during `in-context`, if any differ from the
|
|
* `watching` field of r. Clears the `dirty?` flag on r.
|
|
*
|
|
* Inside '_update-watching' along with adding the ratoms in 'r.watching' of reaction,
|
|
* the reaction is also added to the list of watches on each ratoms f derefs.
|
|
*/
|
|
reagent.ratom.deref_capture = (function reagent$ratom$deref_capture(f,r){
|
|
(r.captured = null);
|
|
|
|
(r.ratomGeneration = (reagent.ratom.generation = (reagent.ratom.generation + (1))));
|
|
|
|
|
|
var res = reagent.ratom.in_context(r,f);
|
|
var c = r.captured;
|
|
(r.dirty_QMARK_ = false);
|
|
|
|
if(reagent.ratom.arr_eq(c,r.watching)){
|
|
} else {
|
|
r._update_watching(c);
|
|
}
|
|
|
|
return res;
|
|
});
|
|
/**
|
|
* Add `derefed` to the `captured` field of `*ratom-context*`.
|
|
*
|
|
* See also `in-context`
|
|
*/
|
|
reagent.ratom.notify_deref_watcher_BANG_ = (function reagent$ratom$notify_deref_watcher_BANG_(derefed){
|
|
var temp__5827__auto__ = reagent.ratom._STAR_ratom_context_STAR_;
|
|
if((temp__5827__auto__ == null)){
|
|
return null;
|
|
} else {
|
|
var r = temp__5827__auto__;
|
|
var c = r.captured;
|
|
if((c == null)){
|
|
return (r.captured = [derefed]);
|
|
} else {
|
|
return c.push(derefed);
|
|
}
|
|
}
|
|
});
|
|
reagent.ratom.check_watches = (function reagent$ratom$check_watches(old,new$){
|
|
if(reagent.ratom.debug){
|
|
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$3(reagent.ratom._running,cljs.core._PLUS_,(cljs.core.count(new$) - cljs.core.count(old)));
|
|
} else {
|
|
}
|
|
|
|
return new$;
|
|
});
|
|
reagent.ratom.add_w = (function reagent$ratom$add_w(this$,key,f){
|
|
var w = this$.watches;
|
|
(this$.watches = reagent.ratom.check_watches(w,cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(w,key,f)));
|
|
|
|
return (this$.watchesArr = null);
|
|
});
|
|
reagent.ratom.remove_w = (function reagent$ratom$remove_w(this$,key){
|
|
var w = this$.watches;
|
|
(this$.watches = reagent.ratom.check_watches(w,cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(w,key)));
|
|
|
|
return (this$.watchesArr = null);
|
|
});
|
|
reagent.ratom.notify_w = (function reagent$ratom$notify_w(this$,old,new$){
|
|
var w = this$.watchesArr;
|
|
var a = (((w == null))?(this$.watchesArr = cljs.core.reduce_kv((function (p1__51661_SHARP_,p2__51662_SHARP_,p3__51663_SHARP_){
|
|
var G__51664 = p1__51661_SHARP_;
|
|
G__51664.push(p2__51662_SHARP_);
|
|
|
|
G__51664.push(p3__51663_SHARP_);
|
|
|
|
return G__51664;
|
|
}),[],this$.watches)):w);
|
|
var len = a.length;
|
|
var i = (0);
|
|
while(true){
|
|
if((i < len)){
|
|
var k_51873 = (a[i]);
|
|
var f_51874 = (a[(i + (1))]);
|
|
(f_51874.cljs$core$IFn$_invoke$arity$4 ? f_51874.cljs$core$IFn$_invoke$arity$4(k_51873,this$,old,new$) : f_51874.call(null,k_51873,this$,old,new$));
|
|
|
|
var G__51875 = ((2) + i);
|
|
i = G__51875;
|
|
continue;
|
|
} else {
|
|
return null;
|
|
}
|
|
break;
|
|
}
|
|
});
|
|
reagent.ratom.pr_atom = (function reagent$ratom$pr_atom(a,writer,opts,s,v){
|
|
cljs.core._write(writer,["#object[reagent.ratom.",cljs.core.str.cljs$core$IFn$_invoke$arity$1(s)," "].join(''));
|
|
|
|
cljs.core.pr_writer((function (){var _STAR_ratom_context_STAR__orig_val__51665 = reagent.ratom._STAR_ratom_context_STAR_;
|
|
var _STAR_ratom_context_STAR__temp_val__51666 = null;
|
|
(reagent.ratom._STAR_ratom_context_STAR_ = _STAR_ratom_context_STAR__temp_val__51666);
|
|
|
|
try{return v;
|
|
}finally {(reagent.ratom._STAR_ratom_context_STAR_ = _STAR_ratom_context_STAR__orig_val__51665);
|
|
}})(),writer,opts);
|
|
|
|
return cljs.core._write(writer,"]");
|
|
});
|
|
if((typeof reagent !== 'undefined') && (typeof reagent.ratom !== 'undefined') && (typeof reagent.ratom.rea_queue !== 'undefined')){
|
|
} else {
|
|
reagent.ratom.rea_queue = null;
|
|
}
|
|
reagent.ratom.rea_enqueue = (function reagent$ratom$rea_enqueue(r){
|
|
if((reagent.ratom.rea_queue == null)){
|
|
(reagent.ratom.rea_queue = []);
|
|
|
|
reagent.impl.batching.schedule();
|
|
} else {
|
|
}
|
|
|
|
return reagent.ratom.rea_queue.push(r);
|
|
});
|
|
|
|
/**
|
|
* @interface
|
|
*/
|
|
reagent.ratom.IReactiveAtom = function(){};
|
|
|
|
|
|
/**
|
|
* @constructor
|
|
* @implements {cljs.core.IWatchable}
|
|
* @implements {cljs.core.IAtom}
|
|
* @implements {cljs.core.IEquiv}
|
|
* @implements {cljs.core.IHash}
|
|
* @implements {cljs.core.IReset}
|
|
* @implements {cljs.core.ISwap}
|
|
* @implements {reagent.ratom.IReactiveAtom}
|
|
* @implements {cljs.core.IMeta}
|
|
* @implements {cljs.core.IDeref}
|
|
* @implements {cljs.core.IPrintWithWriter}
|
|
* @implements {cljs.core.IWithMeta}
|
|
*/
|
|
reagent.ratom.RAtom = (function (state,meta,validator,watches){
|
|
this.state = state;
|
|
this.meta = meta;
|
|
this.validator = validator;
|
|
this.watches = watches;
|
|
this.cljs$lang$protocol_mask$partition0$ = 2154201088;
|
|
this.cljs$lang$protocol_mask$partition1$ = 114690;
|
|
});
|
|
(reagent.ratom.RAtom.prototype.reagent$ratom$IReactiveAtom$ = cljs.core.PROTOCOL_SENTINEL);
|
|
|
|
(reagent.ratom.RAtom.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (a,w,opts){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return reagent.ratom.pr_atom(a__$1,w,opts,"RAtom",new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"val","val",128701612),a__$1.cljs$core$IDeref$_deref$arity$1(null)], null));
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.prototype.cljs$core$IMeta$_meta$arity$1 = (function (_){
|
|
var self__ = this;
|
|
var ___$1 = this;
|
|
return self__.meta;
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.prototype.cljs$core$IHash$_hash$arity$1 = (function (this$){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
return goog.getUid(this$__$1);
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (o,other){
|
|
var self__ = this;
|
|
var o__$1 = this;
|
|
return (o__$1 === other);
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.prototype.cljs$core$IReset$_reset_BANG_$arity$2 = (function (a,new_value){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
if((self__.validator == null)){
|
|
} else {
|
|
if(cljs.core.truth_((self__.validator.cljs$core$IFn$_invoke$arity$1 ? self__.validator.cljs$core$IFn$_invoke$arity$1(new_value) : self__.validator.call(null,new_value)))){
|
|
} else {
|
|
throw (new Error(["Assert failed: ","Validator rejected reference state","\n","(validator new-value)"].join('')));
|
|
}
|
|
}
|
|
|
|
var old_value = self__.state;
|
|
(self__.state = new_value);
|
|
|
|
if((self__.watches == null)){
|
|
} else {
|
|
reagent.ratom.notify_w(a__$1,old_value,new_value);
|
|
}
|
|
|
|
return new_value;
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.prototype.cljs$core$ISwap$_swap_BANG_$arity$2 = (function (a,f){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,(f.cljs$core$IFn$_invoke$arity$1 ? f.cljs$core$IFn$_invoke$arity$1(self__.state) : f.call(null,self__.state)));
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.prototype.cljs$core$ISwap$_swap_BANG_$arity$3 = (function (a,f,x){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,(f.cljs$core$IFn$_invoke$arity$2 ? f.cljs$core$IFn$_invoke$arity$2(self__.state,x) : f.call(null,self__.state,x)));
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.prototype.cljs$core$ISwap$_swap_BANG_$arity$4 = (function (a,f,x,y){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,(f.cljs$core$IFn$_invoke$arity$3 ? f.cljs$core$IFn$_invoke$arity$3(self__.state,x,y) : f.call(null,self__.state,x,y)));
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.prototype.cljs$core$ISwap$_swap_BANG_$arity$5 = (function (a,f,x,y,more){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,cljs.core.apply.cljs$core$IFn$_invoke$arity$5(f,self__.state,x,y,more));
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.prototype.cljs$core$IWatchable$_notify_watches$arity$3 = (function (this$,old,new$){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
return reagent.ratom.notify_w(this$__$1,old,new$);
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.prototype.cljs$core$IWatchable$_add_watch$arity$3 = (function (this$,key,f){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
return reagent.ratom.add_w(this$__$1,key,f);
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.prototype.cljs$core$IWatchable$_remove_watch$arity$2 = (function (this$,key){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
return reagent.ratom.remove_w(this$__$1,key);
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (_,new_meta){
|
|
var self__ = this;
|
|
var ___$1 = this;
|
|
return (new reagent.ratom.RAtom(self__.state,new_meta,self__.validator,self__.watches));
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.prototype.cljs$core$IDeref$_deref$arity$1 = (function (this$){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
reagent.ratom.notify_deref_watcher_BANG_(this$__$1);
|
|
|
|
return self__.state;
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.getBasis = (function (){
|
|
return new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"state","state",-348086572,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"meta","meta",-1154898805,null),new cljs.core.Symbol(null,"validator","validator",-325659154,null),cljs.core.with_meta(new cljs.core.Symbol(null,"watches","watches",1367433992,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
|
|
}));
|
|
|
|
(reagent.ratom.RAtom.cljs$lang$type = true);
|
|
|
|
(reagent.ratom.RAtom.cljs$lang$ctorStr = "reagent.ratom/RAtom");
|
|
|
|
(reagent.ratom.RAtom.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
|
|
return cljs.core._write(writer__5311__auto__,"reagent.ratom/RAtom");
|
|
}));
|
|
|
|
/**
|
|
* Positional factory function for reagent.ratom/RAtom.
|
|
*/
|
|
reagent.ratom.__GT_RAtom = (function reagent$ratom$__GT_RAtom(state,meta,validator,watches){
|
|
return (new reagent.ratom.RAtom(state,meta,validator,watches));
|
|
});
|
|
|
|
/**
|
|
* Like clojure.core/atom, except that it keeps track of derefs.
|
|
*/
|
|
reagent.ratom.atom = (function reagent$ratom$atom(var_args){
|
|
var G__51697 = arguments.length;
|
|
switch (G__51697) {
|
|
case 1:
|
|
return reagent.ratom.atom.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
|
|
|
break;
|
|
default:
|
|
var args_arr__5774__auto__ = [];
|
|
var len__5749__auto___51878 = arguments.length;
|
|
var i__5750__auto___51879 = (0);
|
|
while(true){
|
|
if((i__5750__auto___51879 < len__5749__auto___51878)){
|
|
args_arr__5774__auto__.push((arguments[i__5750__auto___51879]));
|
|
|
|
var G__51883 = (i__5750__auto___51879 + (1));
|
|
i__5750__auto___51879 = G__51883;
|
|
continue;
|
|
} else {
|
|
}
|
|
break;
|
|
}
|
|
|
|
var argseq__5775__auto__ = ((((1) < args_arr__5774__auto__.length))?(new cljs.core.IndexedSeq(args_arr__5774__auto__.slice((1)),(0),null)):null);
|
|
return reagent.ratom.atom.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5775__auto__);
|
|
|
|
}
|
|
});
|
|
|
|
(reagent.ratom.atom.cljs$core$IFn$_invoke$arity$1 = (function (x){
|
|
return reagent.ratom.__GT_RAtom(x,null,null,null);
|
|
}));
|
|
|
|
(reagent.ratom.atom.cljs$core$IFn$_invoke$arity$variadic = (function (x,p__51706){
|
|
var map__51707 = p__51706;
|
|
var map__51707__$1 = cljs.core.__destructure_map(map__51707);
|
|
var meta = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__51707__$1,new cljs.core.Keyword(null,"meta","meta",1499536964));
|
|
var validator = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__51707__$1,new cljs.core.Keyword(null,"validator","validator",-1966190681));
|
|
return reagent.ratom.__GT_RAtom(x,meta,validator,null);
|
|
}));
|
|
|
|
/** @this {Function} */
|
|
(reagent.ratom.atom.cljs$lang$applyTo = (function (seq51693){
|
|
var G__51694 = cljs.core.first(seq51693);
|
|
var seq51693__$1 = cljs.core.next(seq51693);
|
|
var self__5734__auto__ = this;
|
|
return self__5734__auto__.cljs$core$IFn$_invoke$arity$variadic(G__51694,seq51693__$1);
|
|
}));
|
|
|
|
(reagent.ratom.atom.cljs$lang$maxFixedArity = (1));
|
|
|
|
reagent.ratom.cached_reaction = (function reagent$ratom$cached_reaction(f,o,k,obj,destroy){
|
|
var m = o.reagReactionCache;
|
|
var m__$1 = (((m == null))?cljs.core.PersistentArrayMap.EMPTY:m);
|
|
var r = (m__$1.cljs$core$IFn$_invoke$arity$2 ? m__$1.cljs$core$IFn$_invoke$arity$2(k,null) : m__$1.call(null,k,null));
|
|
if((!((r == null)))){
|
|
return cljs.core._deref(r);
|
|
} else {
|
|
if((reagent.ratom._STAR_ratom_context_STAR_ == null)){
|
|
return (f.cljs$core$IFn$_invoke$arity$0 ? f.cljs$core$IFn$_invoke$arity$0() : f.call(null));
|
|
} else {
|
|
var r__$1 = (function (){var G__51712 = f;
|
|
var G__51713 = new cljs.core.Keyword(null,"on-dispose","on-dispose",2105306360);
|
|
var G__51714 = (function (x){
|
|
if(reagent.ratom.debug){
|
|
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$2(reagent.ratom._running,cljs.core.dec);
|
|
} else {
|
|
}
|
|
|
|
var __51884 = o.reagReactionCache;
|
|
var __51885__$1 = cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(__51884,k);
|
|
(o.reagReactionCache = __51885__$1);
|
|
|
|
if((!((obj == null)))){
|
|
(obj.reaction = null);
|
|
} else {
|
|
}
|
|
|
|
if((!((destroy == null)))){
|
|
return (destroy.cljs$core$IFn$_invoke$arity$1 ? destroy.cljs$core$IFn$_invoke$arity$1(x) : destroy.call(null,x));
|
|
} else {
|
|
return null;
|
|
}
|
|
});
|
|
return (reagent.ratom.make_reaction.cljs$core$IFn$_invoke$arity$3 ? reagent.ratom.make_reaction.cljs$core$IFn$_invoke$arity$3(G__51712,G__51713,G__51714) : reagent.ratom.make_reaction.call(null,G__51712,G__51713,G__51714));
|
|
})();
|
|
var v = cljs.core._deref(r__$1);
|
|
(o.reagReactionCache = cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(m__$1,k,r__$1));
|
|
|
|
if(reagent.ratom.debug){
|
|
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$2(reagent.ratom._running,cljs.core.inc);
|
|
} else {
|
|
}
|
|
|
|
if((!((obj == null)))){
|
|
(obj.reaction = r__$1);
|
|
} else {
|
|
}
|
|
|
|
return v;
|
|
|
|
}
|
|
}
|
|
});
|
|
|
|
/**
|
|
* @constructor
|
|
* @implements {cljs.core.IEquiv}
|
|
* @implements {cljs.core.IHash}
|
|
* @implements {reagent.ratom.IReactiveAtom}
|
|
* @implements {cljs.core.IDeref}
|
|
* @implements {cljs.core.IPrintWithWriter}
|
|
*/
|
|
reagent.ratom.Track = (function (f,args,reaction){
|
|
this.f = f;
|
|
this.args = args;
|
|
this.reaction = reaction;
|
|
this.cljs$lang$protocol_mask$partition0$ = 2153807872;
|
|
this.cljs$lang$protocol_mask$partition1$ = 0;
|
|
});
|
|
(reagent.ratom.Track.prototype.reagent$ratom$IReactiveAtom$ = cljs.core.PROTOCOL_SENTINEL);
|
|
|
|
(reagent.ratom.Track.prototype.cljs$core$IDeref$_deref$arity$1 = (function (this$){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
var temp__5825__auto__ = self__.reaction;
|
|
if((temp__5825__auto__ == null)){
|
|
return reagent.ratom.cached_reaction((function (){
|
|
return cljs.core.apply.cljs$core$IFn$_invoke$arity$2(self__.f,self__.args);
|
|
}),self__.f,self__.args,this$__$1,null);
|
|
} else {
|
|
var r = temp__5825__auto__;
|
|
return cljs.core._deref(r);
|
|
}
|
|
}));
|
|
|
|
(reagent.ratom.Track.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (_,other){
|
|
var self__ = this;
|
|
var ___$1 = this;
|
|
return (((other instanceof reagent.ratom.Track)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(self__.f,other.f)) && (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(self__.args,other.args)))));
|
|
}));
|
|
|
|
(reagent.ratom.Track.prototype.cljs$core$IHash$_hash$arity$1 = (function (_){
|
|
var self__ = this;
|
|
var ___$1 = this;
|
|
return cljs.core.hash(new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [self__.f,self__.args], null));
|
|
}));
|
|
|
|
(reagent.ratom.Track.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (a,w,opts){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return reagent.ratom.pr_atom(a__$1,w,opts,"Track",new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"val","val",128701612),a__$1.cljs$core$IDeref$_deref$arity$1(null),new cljs.core.Keyword(null,"f","f",-1597136552),self__.f], null));
|
|
}));
|
|
|
|
(reagent.ratom.Track.getBasis = (function (){
|
|
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"f","f",43394975,null),new cljs.core.Symbol(null,"args","args",-1338879193,null),cljs.core.with_meta(new cljs.core.Symbol(null,"reaction","reaction",2131401315,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
|
|
}));
|
|
|
|
(reagent.ratom.Track.cljs$lang$type = true);
|
|
|
|
(reagent.ratom.Track.cljs$lang$ctorStr = "reagent.ratom/Track");
|
|
|
|
(reagent.ratom.Track.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
|
|
return cljs.core._write(writer__5311__auto__,"reagent.ratom/Track");
|
|
}));
|
|
|
|
/**
|
|
* Positional factory function for reagent.ratom/Track.
|
|
*/
|
|
reagent.ratom.__GT_Track = (function reagent$ratom$__GT_Track(f,args,reaction){
|
|
return (new reagent.ratom.Track(f,args,reaction));
|
|
});
|
|
|
|
reagent.ratom.make_track = (function reagent$ratom$make_track(f,args){
|
|
return (new reagent.ratom.Track(f,args,null));
|
|
});
|
|
reagent.ratom.make_track_BANG_ = (function reagent$ratom$make_track_BANG_(f,args){
|
|
var t = reagent.ratom.make_track(f,args);
|
|
var r = (function (){var G__51748 = (function (){
|
|
return t.cljs$core$IDeref$_deref$arity$1(null);
|
|
});
|
|
var G__51749 = new cljs.core.Keyword(null,"auto-run","auto-run",1958400437);
|
|
var G__51750 = true;
|
|
return (reagent.ratom.make_reaction.cljs$core$IFn$_invoke$arity$3 ? reagent.ratom.make_reaction.cljs$core$IFn$_invoke$arity$3(G__51748,G__51749,G__51750) : reagent.ratom.make_reaction.call(null,G__51748,G__51749,G__51750));
|
|
})();
|
|
cljs.core.deref(r);
|
|
|
|
return r;
|
|
});
|
|
reagent.ratom.track = (function reagent$ratom$track(var_args){
|
|
var args__5755__auto__ = [];
|
|
var len__5749__auto___51891 = arguments.length;
|
|
var i__5750__auto___51892 = (0);
|
|
while(true){
|
|
if((i__5750__auto___51892 < len__5749__auto___51891)){
|
|
args__5755__auto__.push((arguments[i__5750__auto___51892]));
|
|
|
|
var G__51893 = (i__5750__auto___51892 + (1));
|
|
i__5750__auto___51892 = G__51893;
|
|
continue;
|
|
} else {
|
|
}
|
|
break;
|
|
}
|
|
|
|
var argseq__5756__auto__ = ((((1) < args__5755__auto__.length))?(new cljs.core.IndexedSeq(args__5755__auto__.slice((1)),(0),null)):null);
|
|
return reagent.ratom.track.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5756__auto__);
|
|
});
|
|
|
|
(reagent.ratom.track.cljs$core$IFn$_invoke$arity$variadic = (function (f,args){
|
|
if(cljs.core.ifn_QMARK_(f)){
|
|
} else {
|
|
throw (new Error("Assert failed: (ifn? f)"));
|
|
}
|
|
|
|
return reagent.ratom.make_track(f,args);
|
|
}));
|
|
|
|
(reagent.ratom.track.cljs$lang$maxFixedArity = (1));
|
|
|
|
/** @this {Function} */
|
|
(reagent.ratom.track.cljs$lang$applyTo = (function (seq51751){
|
|
var G__51752 = cljs.core.first(seq51751);
|
|
var seq51751__$1 = cljs.core.next(seq51751);
|
|
var self__5734__auto__ = this;
|
|
return self__5734__auto__.cljs$core$IFn$_invoke$arity$variadic(G__51752,seq51751__$1);
|
|
}));
|
|
|
|
reagent.ratom.track_BANG_ = (function reagent$ratom$track_BANG_(var_args){
|
|
var args__5755__auto__ = [];
|
|
var len__5749__auto___51894 = arguments.length;
|
|
var i__5750__auto___51895 = (0);
|
|
while(true){
|
|
if((i__5750__auto___51895 < len__5749__auto___51894)){
|
|
args__5755__auto__.push((arguments[i__5750__auto___51895]));
|
|
|
|
var G__51896 = (i__5750__auto___51895 + (1));
|
|
i__5750__auto___51895 = G__51896;
|
|
continue;
|
|
} else {
|
|
}
|
|
break;
|
|
}
|
|
|
|
var argseq__5756__auto__ = ((((1) < args__5755__auto__.length))?(new cljs.core.IndexedSeq(args__5755__auto__.slice((1)),(0),null)):null);
|
|
return reagent.ratom.track_BANG_.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5756__auto__);
|
|
});
|
|
|
|
(reagent.ratom.track_BANG_.cljs$core$IFn$_invoke$arity$variadic = (function (f,args){
|
|
if(cljs.core.ifn_QMARK_(f)){
|
|
} else {
|
|
throw (new Error("Assert failed: (ifn? f)"));
|
|
}
|
|
|
|
return reagent.ratom.make_track_BANG_(f,args);
|
|
}));
|
|
|
|
(reagent.ratom.track_BANG_.cljs$lang$maxFixedArity = (1));
|
|
|
|
/** @this {Function} */
|
|
(reagent.ratom.track_BANG_.cljs$lang$applyTo = (function (seq51762){
|
|
var G__51763 = cljs.core.first(seq51762);
|
|
var seq51762__$1 = cljs.core.next(seq51762);
|
|
var self__5734__auto__ = this;
|
|
return self__5734__auto__.cljs$core$IFn$_invoke$arity$variadic(G__51763,seq51762__$1);
|
|
}));
|
|
|
|
|
|
/**
|
|
* @constructor
|
|
* @implements {cljs.core.IWatchable}
|
|
* @implements {cljs.core.IAtom}
|
|
* @implements {cljs.core.IEquiv}
|
|
* @implements {cljs.core.IHash}
|
|
* @implements {cljs.core.IReset}
|
|
* @implements {cljs.core.ISwap}
|
|
* @implements {reagent.ratom.IReactiveAtom}
|
|
* @implements {cljs.core.IDeref}
|
|
* @implements {cljs.core.IPrintWithWriter}
|
|
*/
|
|
reagent.ratom.RCursor = (function (ratom,path,reaction,state,watches){
|
|
this.ratom = ratom;
|
|
this.path = path;
|
|
this.reaction = reaction;
|
|
this.state = state;
|
|
this.watches = watches;
|
|
this.cljs$lang$protocol_mask$partition0$ = 2153807872;
|
|
this.cljs$lang$protocol_mask$partition1$ = 114690;
|
|
});
|
|
(reagent.ratom.RCursor.prototype._peek = (function (){
|
|
var self__ = this;
|
|
var this$ = this;
|
|
var _STAR_ratom_context_STAR__orig_val__51799 = reagent.ratom._STAR_ratom_context_STAR_;
|
|
var _STAR_ratom_context_STAR__temp_val__51800 = null;
|
|
(reagent.ratom._STAR_ratom_context_STAR_ = _STAR_ratom_context_STAR__temp_val__51800);
|
|
|
|
try{return this$.cljs$core$IDeref$_deref$arity$1(null);
|
|
}finally {(reagent.ratom._STAR_ratom_context_STAR_ = _STAR_ratom_context_STAR__orig_val__51799);
|
|
}}));
|
|
|
|
(reagent.ratom.RCursor.prototype._set_state = (function (oldstate,newstate){
|
|
var self__ = this;
|
|
var this$ = this;
|
|
if((oldstate === newstate)){
|
|
return null;
|
|
} else {
|
|
(self__.state = newstate);
|
|
|
|
if((!((self__.watches == null)))){
|
|
return reagent.ratom.notify_w(this$,oldstate,newstate);
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
}));
|
|
|
|
(reagent.ratom.RCursor.prototype.reagent$ratom$IReactiveAtom$ = cljs.core.PROTOCOL_SENTINEL);
|
|
|
|
(reagent.ratom.RCursor.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (a,w,opts){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return reagent.ratom.pr_atom(a__$1,w,opts,"RCursor",new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"val","val",128701612),a__$1.cljs$core$IDeref$_deref$arity$1(null),new cljs.core.Keyword(null,"path","path",-188191168),self__.path], null));
|
|
}));
|
|
|
|
(reagent.ratom.RCursor.prototype.cljs$core$IHash$_hash$arity$1 = (function (_){
|
|
var self__ = this;
|
|
var ___$1 = this;
|
|
return cljs.core.hash(new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [self__.ratom,self__.path], null));
|
|
}));
|
|
|
|
(reagent.ratom.RCursor.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (_,other){
|
|
var self__ = this;
|
|
var ___$1 = this;
|
|
return (((other instanceof reagent.ratom.RCursor)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(self__.path,other.path)) && (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(self__.ratom,other.ratom)))));
|
|
}));
|
|
|
|
(reagent.ratom.RCursor.prototype.cljs$core$IReset$_reset_BANG_$arity$2 = (function (this$,new_value){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
var oldstate = self__.state;
|
|
this$__$1._set_state(oldstate,new_value);
|
|
|
|
if((((!((self__.ratom == null))))?(((((self__.ratom.cljs$lang$protocol_mask$partition0$ & (32768))) || ((cljs.core.PROTOCOL_SENTINEL === self__.ratom.cljs$core$IDeref$))))?true:(((!self__.ratom.cljs$lang$protocol_mask$partition0$))?cljs.core.native_satisfies_QMARK_(cljs.core.IDeref,self__.ratom):false)):cljs.core.native_satisfies_QMARK_(cljs.core.IDeref,self__.ratom))){
|
|
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(self__.path,cljs.core.PersistentVector.EMPTY)){
|
|
cljs.core.reset_BANG_(self__.ratom,new_value);
|
|
} else {
|
|
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4(self__.ratom,cljs.core.assoc_in,self__.path,new_value);
|
|
}
|
|
} else {
|
|
(self__.ratom.cljs$core$IFn$_invoke$arity$2 ? self__.ratom.cljs$core$IFn$_invoke$arity$2(self__.path,new_value) : self__.ratom.call(null,self__.path,new_value));
|
|
}
|
|
|
|
return new_value;
|
|
}));
|
|
|
|
(reagent.ratom.RCursor.prototype.cljs$core$ISwap$_swap_BANG_$arity$2 = (function (a,f){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,(function (){var G__51804 = a__$1._peek();
|
|
return (f.cljs$core$IFn$_invoke$arity$1 ? f.cljs$core$IFn$_invoke$arity$1(G__51804) : f.call(null,G__51804));
|
|
})());
|
|
}));
|
|
|
|
(reagent.ratom.RCursor.prototype.cljs$core$ISwap$_swap_BANG_$arity$3 = (function (a,f,x){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,(function (){var G__51805 = a__$1._peek();
|
|
var G__51806 = x;
|
|
return (f.cljs$core$IFn$_invoke$arity$2 ? f.cljs$core$IFn$_invoke$arity$2(G__51805,G__51806) : f.call(null,G__51805,G__51806));
|
|
})());
|
|
}));
|
|
|
|
(reagent.ratom.RCursor.prototype.cljs$core$ISwap$_swap_BANG_$arity$4 = (function (a,f,x,y){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,(function (){var G__51807 = a__$1._peek();
|
|
var G__51808 = x;
|
|
var G__51809 = y;
|
|
return (f.cljs$core$IFn$_invoke$arity$3 ? f.cljs$core$IFn$_invoke$arity$3(G__51807,G__51808,G__51809) : f.call(null,G__51807,G__51808,G__51809));
|
|
})());
|
|
}));
|
|
|
|
(reagent.ratom.RCursor.prototype.cljs$core$ISwap$_swap_BANG_$arity$5 = (function (a,f,x,y,more){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,cljs.core.apply.cljs$core$IFn$_invoke$arity$5(f,a__$1._peek(),x,y,more));
|
|
}));
|
|
|
|
(reagent.ratom.RCursor.prototype.cljs$core$IWatchable$_notify_watches$arity$3 = (function (this$,old,new$){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
return reagent.ratom.notify_w(this$__$1,old,new$);
|
|
}));
|
|
|
|
(reagent.ratom.RCursor.prototype.cljs$core$IWatchable$_add_watch$arity$3 = (function (this$,key,f){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
return reagent.ratom.add_w(this$__$1,key,f);
|
|
}));
|
|
|
|
(reagent.ratom.RCursor.prototype.cljs$core$IWatchable$_remove_watch$arity$2 = (function (this$,key){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
return reagent.ratom.remove_w(this$__$1,key);
|
|
}));
|
|
|
|
(reagent.ratom.RCursor.prototype.cljs$core$IDeref$_deref$arity$1 = (function (this$){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
var oldstate = self__.state;
|
|
var newstate = (function (){var temp__5825__auto__ = self__.reaction;
|
|
if((temp__5825__auto__ == null)){
|
|
var f = (((((!((self__.ratom == null))))?(((((self__.ratom.cljs$lang$protocol_mask$partition0$ & (32768))) || ((cljs.core.PROTOCOL_SENTINEL === self__.ratom.cljs$core$IDeref$))))?true:(((!self__.ratom.cljs$lang$protocol_mask$partition0$))?cljs.core.native_satisfies_QMARK_(cljs.core.IDeref,self__.ratom):false)):cljs.core.native_satisfies_QMARK_(cljs.core.IDeref,self__.ratom)))?(function (){
|
|
return cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(cljs.core.deref(self__.ratom),self__.path);
|
|
}):(function (){
|
|
return (self__.ratom.cljs$core$IFn$_invoke$arity$1 ? self__.ratom.cljs$core$IFn$_invoke$arity$1(self__.path) : self__.ratom.call(null,self__.path));
|
|
}));
|
|
return reagent.ratom.cached_reaction(f,self__.ratom,self__.path,this$__$1,null);
|
|
} else {
|
|
var r = temp__5825__auto__;
|
|
return cljs.core._deref(r);
|
|
}
|
|
})();
|
|
this$__$1._set_state(oldstate,newstate);
|
|
|
|
return newstate;
|
|
}));
|
|
|
|
(reagent.ratom.RCursor.getBasis = (function (){
|
|
return new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"ratom","ratom",1514010260,null),new cljs.core.Symbol(null,"path","path",1452340359,null),cljs.core.with_meta(new cljs.core.Symbol(null,"reaction","reaction",2131401315,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"state","state",-348086572,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"watches","watches",1367433992,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
|
|
}));
|
|
|
|
(reagent.ratom.RCursor.cljs$lang$type = true);
|
|
|
|
(reagent.ratom.RCursor.cljs$lang$ctorStr = "reagent.ratom/RCursor");
|
|
|
|
(reagent.ratom.RCursor.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
|
|
return cljs.core._write(writer__5311__auto__,"reagent.ratom/RCursor");
|
|
}));
|
|
|
|
/**
|
|
* Positional factory function for reagent.ratom/RCursor.
|
|
*/
|
|
reagent.ratom.__GT_RCursor = (function reagent$ratom$__GT_RCursor(ratom,path,reaction,state,watches){
|
|
return (new reagent.ratom.RCursor(ratom,path,reaction,state,watches));
|
|
});
|
|
|
|
reagent.ratom.cursor = (function reagent$ratom$cursor(src,path){
|
|
if((function (){var or__5025__auto__ = (((!((src == null))))?((((false) || ((cljs.core.PROTOCOL_SENTINEL === src.reagent$ratom$IReactiveAtom$))))?true:(((!src.cljs$lang$protocol_mask$partition$))?cljs.core.native_satisfies_QMARK_(reagent.ratom.IReactiveAtom,src):false)):cljs.core.native_satisfies_QMARK_(reagent.ratom.IReactiveAtom,src));
|
|
if(or__5025__auto__){
|
|
return or__5025__auto__;
|
|
} else {
|
|
return ((cljs.core.ifn_QMARK_(src)) && ((!(cljs.core.vector_QMARK_(src)))));
|
|
}
|
|
})()){
|
|
} else {
|
|
throw (new Error(["Assert failed: ",["src must be a reactive atom or a function, not ",cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([src], 0))," while attempting to get path: ",cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([path], 0))].join(''),"\n","(or (satisfies? IReactiveAtom src) (and (ifn? src) (not (vector? src))))"].join('')));
|
|
}
|
|
|
|
return reagent.ratom.__GT_RCursor(src,path,null,null,null);
|
|
});
|
|
reagent.ratom.with_let_destroy = (function reagent$ratom$with_let_destroy(v){
|
|
var temp__5827__auto__ = v.destroy;
|
|
if((temp__5827__auto__ == null)){
|
|
return null;
|
|
} else {
|
|
var f = temp__5827__auto__;
|
|
return (f.cljs$core$IFn$_invoke$arity$0 ? f.cljs$core$IFn$_invoke$arity$0() : f.call(null));
|
|
}
|
|
});
|
|
reagent.ratom.with_let_values = (function reagent$ratom$with_let_values(key){
|
|
var temp__5825__auto__ = reagent.ratom._STAR_ratom_context_STAR_;
|
|
if((temp__5825__auto__ == null)){
|
|
return [];
|
|
} else {
|
|
var c = temp__5825__auto__;
|
|
return reagent.ratom.cached_reaction(cljs.core.array,c,key,null,reagent.ratom.with_let_destroy);
|
|
}
|
|
});
|
|
|
|
/**
|
|
* @interface
|
|
*/
|
|
reagent.ratom.IDisposable = function(){};
|
|
|
|
var reagent$ratom$IDisposable$dispose_BANG_$dyn_51899 = (function (this$){
|
|
var x__5373__auto__ = (((this$ == null))?null:this$);
|
|
var m__5374__auto__ = (reagent.ratom.dispose_BANG_[goog.typeOf(x__5373__auto__)]);
|
|
if((!((m__5374__auto__ == null)))){
|
|
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5374__auto__.call(null,this$));
|
|
} else {
|
|
var m__5372__auto__ = (reagent.ratom.dispose_BANG_["_"]);
|
|
if((!((m__5372__auto__ == null)))){
|
|
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5372__auto__.call(null,this$));
|
|
} else {
|
|
throw cljs.core.missing_protocol("IDisposable.dispose!",this$);
|
|
}
|
|
}
|
|
});
|
|
reagent.ratom.dispose_BANG_ = (function reagent$ratom$dispose_BANG_(this$){
|
|
if((((!((this$ == null)))) && ((!((this$.reagent$ratom$IDisposable$dispose_BANG_$arity$1 == null)))))){
|
|
return this$.reagent$ratom$IDisposable$dispose_BANG_$arity$1(this$);
|
|
} else {
|
|
return reagent$ratom$IDisposable$dispose_BANG_$dyn_51899(this$);
|
|
}
|
|
});
|
|
|
|
var reagent$ratom$IDisposable$add_on_dispose_BANG_$dyn_51901 = (function (this$,f){
|
|
var x__5373__auto__ = (((this$ == null))?null:this$);
|
|
var m__5374__auto__ = (reagent.ratom.add_on_dispose_BANG_[goog.typeOf(x__5373__auto__)]);
|
|
if((!((m__5374__auto__ == null)))){
|
|
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$2(this$,f) : m__5374__auto__.call(null,this$,f));
|
|
} else {
|
|
var m__5372__auto__ = (reagent.ratom.add_on_dispose_BANG_["_"]);
|
|
if((!((m__5372__auto__ == null)))){
|
|
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$2(this$,f) : m__5372__auto__.call(null,this$,f));
|
|
} else {
|
|
throw cljs.core.missing_protocol("IDisposable.add-on-dispose!",this$);
|
|
}
|
|
}
|
|
});
|
|
reagent.ratom.add_on_dispose_BANG_ = (function reagent$ratom$add_on_dispose_BANG_(this$,f){
|
|
if((((!((this$ == null)))) && ((!((this$.reagent$ratom$IDisposable$add_on_dispose_BANG_$arity$2 == null)))))){
|
|
return this$.reagent$ratom$IDisposable$add_on_dispose_BANG_$arity$2(this$,f);
|
|
} else {
|
|
return reagent$ratom$IDisposable$add_on_dispose_BANG_$dyn_51901(this$,f);
|
|
}
|
|
});
|
|
|
|
|
|
/**
|
|
* @interface
|
|
*/
|
|
reagent.ratom.IRunnable = function(){};
|
|
|
|
var reagent$ratom$IRunnable$run$dyn_51902 = (function (this$){
|
|
var x__5373__auto__ = (((this$ == null))?null:this$);
|
|
var m__5374__auto__ = (reagent.ratom.run[goog.typeOf(x__5373__auto__)]);
|
|
if((!((m__5374__auto__ == null)))){
|
|
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5374__auto__.call(null,this$));
|
|
} else {
|
|
var m__5372__auto__ = (reagent.ratom.run["_"]);
|
|
if((!((m__5372__auto__ == null)))){
|
|
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5372__auto__.call(null,this$));
|
|
} else {
|
|
throw cljs.core.missing_protocol("IRunnable.run",this$);
|
|
}
|
|
}
|
|
});
|
|
reagent.ratom.run = (function reagent$ratom$run(this$){
|
|
if((((!((this$ == null)))) && ((!((this$.reagent$ratom$IRunnable$run$arity$1 == null)))))){
|
|
return this$.reagent$ratom$IRunnable$run$arity$1(this$);
|
|
} else {
|
|
return reagent$ratom$IRunnable$run$dyn_51902(this$);
|
|
}
|
|
});
|
|
|
|
reagent.ratom.handle_reaction_change = (function reagent$ratom$handle_reaction_change(this$,sender,old,new$){
|
|
return this$._handle_change(sender,old,new$);
|
|
});
|
|
|
|
/**
|
|
* @constructor
|
|
* @implements {cljs.core.IWatchable}
|
|
* @implements {cljs.core.IAtom}
|
|
* @implements {cljs.core.IEquiv}
|
|
* @implements {cljs.core.IHash}
|
|
* @implements {cljs.core.IReset}
|
|
* @implements {cljs.core.ISwap}
|
|
* @implements {reagent.ratom.IReactiveAtom}
|
|
* @implements {reagent.ratom.IRunnable}
|
|
* @implements {reagent.ratom.IDisposable}
|
|
* @implements {cljs.core.IDeref}
|
|
* @implements {cljs.core.IPrintWithWriter}
|
|
*/
|
|
reagent.ratom.Reaction = (function (f,state,dirty_QMARK_,nocache_QMARK_,watching,watches,auto_run,caught){
|
|
this.f = f;
|
|
this.state = state;
|
|
this.dirty_QMARK_ = dirty_QMARK_;
|
|
this.nocache_QMARK_ = nocache_QMARK_;
|
|
this.watching = watching;
|
|
this.watches = watches;
|
|
this.auto_run = auto_run;
|
|
this.caught = caught;
|
|
this.cljs$lang$protocol_mask$partition0$ = 2153807872;
|
|
this.cljs$lang$protocol_mask$partition1$ = 114690;
|
|
});
|
|
(reagent.ratom.Reaction.prototype._peek_at = (function (){
|
|
var self__ = this;
|
|
var this$ = this;
|
|
var _STAR_ratom_context_STAR__orig_val__51830 = reagent.ratom._STAR_ratom_context_STAR_;
|
|
var _STAR_ratom_context_STAR__temp_val__51831 = null;
|
|
(reagent.ratom._STAR_ratom_context_STAR_ = _STAR_ratom_context_STAR__temp_val__51831);
|
|
|
|
try{return this$.cljs$core$IDeref$_deref$arity$1(null);
|
|
}finally {(reagent.ratom._STAR_ratom_context_STAR_ = _STAR_ratom_context_STAR__orig_val__51830);
|
|
}}));
|
|
|
|
(reagent.ratom.Reaction.prototype._handle_change = (function (sender,oldval,newval){
|
|
var self__ = this;
|
|
var this$ = this;
|
|
if((((oldval === newval)) || (self__.dirty_QMARK_))){
|
|
return null;
|
|
} else {
|
|
if((self__.auto_run == null)){
|
|
(self__.dirty_QMARK_ = true);
|
|
|
|
return reagent.ratom.rea_enqueue(this$);
|
|
} else {
|
|
if(self__.auto_run === true){
|
|
return this$._run(false);
|
|
} else {
|
|
return (self__.auto_run.cljs$core$IFn$_invoke$arity$1 ? self__.auto_run.cljs$core$IFn$_invoke$arity$1(this$) : self__.auto_run.call(null,this$));
|
|
}
|
|
}
|
|
}
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype._update_watching = (function (derefed){
|
|
var self__ = this;
|
|
var this$ = this;
|
|
var new$ = cljs.core.set(derefed);
|
|
var old = cljs.core.set(self__.watching);
|
|
(self__.watching = derefed);
|
|
|
|
var seq__51832_51903 = cljs.core.seq(clojure.set.difference.cljs$core$IFn$_invoke$arity$2(new$,old));
|
|
var chunk__51833_51904 = null;
|
|
var count__51834_51906 = (0);
|
|
var i__51835_51907 = (0);
|
|
while(true){
|
|
if((i__51835_51907 < count__51834_51906)){
|
|
var w_51908 = chunk__51833_51904.cljs$core$IIndexed$_nth$arity$2(null,i__51835_51907);
|
|
cljs.core._add_watch(w_51908,this$,reagent.ratom.handle_reaction_change);
|
|
|
|
|
|
var G__51909 = seq__51832_51903;
|
|
var G__51910 = chunk__51833_51904;
|
|
var G__51911 = count__51834_51906;
|
|
var G__51912 = (i__51835_51907 + (1));
|
|
seq__51832_51903 = G__51909;
|
|
chunk__51833_51904 = G__51910;
|
|
count__51834_51906 = G__51911;
|
|
i__51835_51907 = G__51912;
|
|
continue;
|
|
} else {
|
|
var temp__5823__auto___51914 = cljs.core.seq(seq__51832_51903);
|
|
if(temp__5823__auto___51914){
|
|
var seq__51832_51915__$1 = temp__5823__auto___51914;
|
|
if(cljs.core.chunked_seq_QMARK_(seq__51832_51915__$1)){
|
|
var c__5548__auto___51916 = cljs.core.chunk_first(seq__51832_51915__$1);
|
|
var G__51917 = cljs.core.chunk_rest(seq__51832_51915__$1);
|
|
var G__51918 = c__5548__auto___51916;
|
|
var G__51919 = cljs.core.count(c__5548__auto___51916);
|
|
var G__51920 = (0);
|
|
seq__51832_51903 = G__51917;
|
|
chunk__51833_51904 = G__51918;
|
|
count__51834_51906 = G__51919;
|
|
i__51835_51907 = G__51920;
|
|
continue;
|
|
} else {
|
|
var w_51921 = cljs.core.first(seq__51832_51915__$1);
|
|
cljs.core._add_watch(w_51921,this$,reagent.ratom.handle_reaction_change);
|
|
|
|
|
|
var G__51922 = cljs.core.next(seq__51832_51915__$1);
|
|
var G__51923 = null;
|
|
var G__51924 = (0);
|
|
var G__51925 = (0);
|
|
seq__51832_51903 = G__51922;
|
|
chunk__51833_51904 = G__51923;
|
|
count__51834_51906 = G__51924;
|
|
i__51835_51907 = G__51925;
|
|
continue;
|
|
}
|
|
} else {
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
var seq__51836 = cljs.core.seq(clojure.set.difference.cljs$core$IFn$_invoke$arity$2(old,new$));
|
|
var chunk__51837 = null;
|
|
var count__51838 = (0);
|
|
var i__51839 = (0);
|
|
while(true){
|
|
if((i__51839 < count__51838)){
|
|
var w = chunk__51837.cljs$core$IIndexed$_nth$arity$2(null,i__51839);
|
|
cljs.core._remove_watch(w,this$);
|
|
|
|
|
|
var G__51926 = seq__51836;
|
|
var G__51927 = chunk__51837;
|
|
var G__51928 = count__51838;
|
|
var G__51929 = (i__51839 + (1));
|
|
seq__51836 = G__51926;
|
|
chunk__51837 = G__51927;
|
|
count__51838 = G__51928;
|
|
i__51839 = G__51929;
|
|
continue;
|
|
} else {
|
|
var temp__5823__auto__ = cljs.core.seq(seq__51836);
|
|
if(temp__5823__auto__){
|
|
var seq__51836__$1 = temp__5823__auto__;
|
|
if(cljs.core.chunked_seq_QMARK_(seq__51836__$1)){
|
|
var c__5548__auto__ = cljs.core.chunk_first(seq__51836__$1);
|
|
var G__51930 = cljs.core.chunk_rest(seq__51836__$1);
|
|
var G__51931 = c__5548__auto__;
|
|
var G__51932 = cljs.core.count(c__5548__auto__);
|
|
var G__51933 = (0);
|
|
seq__51836 = G__51930;
|
|
chunk__51837 = G__51931;
|
|
count__51838 = G__51932;
|
|
i__51839 = G__51933;
|
|
continue;
|
|
} else {
|
|
var w = cljs.core.first(seq__51836__$1);
|
|
cljs.core._remove_watch(w,this$);
|
|
|
|
|
|
var G__51934 = cljs.core.next(seq__51836__$1);
|
|
var G__51935 = null;
|
|
var G__51936 = (0);
|
|
var G__51937 = (0);
|
|
seq__51836 = G__51934;
|
|
chunk__51837 = G__51935;
|
|
count__51838 = G__51936;
|
|
i__51839 = G__51937;
|
|
continue;
|
|
}
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype._queued_run = (function (){
|
|
var self__ = this;
|
|
var this$ = this;
|
|
if(((self__.dirty_QMARK_) && ((!((self__.watching == null)))))){
|
|
return this$._run(true);
|
|
} else {
|
|
return null;
|
|
}
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype._try_capture = (function (f__$1){
|
|
var self__ = this;
|
|
var this$ = this;
|
|
try{(self__.caught = null);
|
|
|
|
return reagent.ratom.deref_capture(f__$1,this$);
|
|
}catch (e51840){var e = e51840;
|
|
(self__.state = e);
|
|
|
|
(self__.caught = e);
|
|
|
|
return (self__.dirty_QMARK_ = false);
|
|
}}));
|
|
|
|
(reagent.ratom.Reaction.prototype._run = (function (check){
|
|
var self__ = this;
|
|
var this$ = this;
|
|
var oldstate = self__.state;
|
|
var res = (cljs.core.truth_(check)?this$._try_capture(self__.f):reagent.ratom.deref_capture(self__.f,this$));
|
|
if(self__.nocache_QMARK_){
|
|
} else {
|
|
(self__.state = res);
|
|
|
|
if((((self__.watches == null)) || (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(oldstate,res)))){
|
|
} else {
|
|
reagent.ratom.notify_w(this$,oldstate,res);
|
|
}
|
|
}
|
|
|
|
return res;
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype._set_opts = (function (p__51844){
|
|
var self__ = this;
|
|
var map__51845 = p__51844;
|
|
var map__51845__$1 = cljs.core.__destructure_map(map__51845);
|
|
var auto_run__$1 = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__51845__$1,new cljs.core.Keyword(null,"auto-run","auto-run",1958400437));
|
|
var on_set = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__51845__$1,new cljs.core.Keyword(null,"on-set","on-set",-140953470));
|
|
var on_dispose = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__51845__$1,new cljs.core.Keyword(null,"on-dispose","on-dispose",2105306360));
|
|
var no_cache = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__51845__$1,new cljs.core.Keyword(null,"no-cache","no-cache",1588056370));
|
|
var this$ = this;
|
|
if((!((auto_run__$1 == null)))){
|
|
(this$.auto_run = auto_run__$1);
|
|
} else {
|
|
}
|
|
|
|
if((!((on_set == null)))){
|
|
(this$.on_set = on_set);
|
|
} else {
|
|
}
|
|
|
|
if((!((on_dispose == null)))){
|
|
(this$.on_dispose = on_dispose);
|
|
} else {
|
|
}
|
|
|
|
if((!((no_cache == null)))){
|
|
return (this$.nocache_QMARK_ = no_cache);
|
|
} else {
|
|
return null;
|
|
}
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.reagent$ratom$IReactiveAtom$ = cljs.core.PROTOCOL_SENTINEL);
|
|
|
|
(reagent.ratom.Reaction.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (a,w,opts){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return reagent.ratom.pr_atom(a__$1,w,opts,"Reaction",new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"val","val",128701612),a__$1.cljs$core$IDeref$_deref$arity$1(null)], null));
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.cljs$core$IHash$_hash$arity$1 = (function (this$){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
return goog.getUid(this$__$1);
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (o,other){
|
|
var self__ = this;
|
|
var o__$1 = this;
|
|
return (o__$1 === other);
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.reagent$ratom$IDisposable$ = cljs.core.PROTOCOL_SENTINEL);
|
|
|
|
(reagent.ratom.Reaction.prototype.reagent$ratom$IDisposable$dispose_BANG_$arity$1 = (function (this$){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
var s = self__.state;
|
|
var wg = self__.watching;
|
|
(self__.watching = null);
|
|
|
|
(self__.state = null);
|
|
|
|
(self__.auto_run = null);
|
|
|
|
(self__.dirty_QMARK_ = true);
|
|
|
|
var seq__51849_51940 = cljs.core.seq(cljs.core.set(wg));
|
|
var chunk__51850_51941 = null;
|
|
var count__51851_51942 = (0);
|
|
var i__51852_51943 = (0);
|
|
while(true){
|
|
if((i__51852_51943 < count__51851_51942)){
|
|
var w_51945 = chunk__51850_51941.cljs$core$IIndexed$_nth$arity$2(null,i__51852_51943);
|
|
cljs.core._remove_watch(w_51945,this$__$1);
|
|
|
|
|
|
var G__51946 = seq__51849_51940;
|
|
var G__51947 = chunk__51850_51941;
|
|
var G__51948 = count__51851_51942;
|
|
var G__51949 = (i__51852_51943 + (1));
|
|
seq__51849_51940 = G__51946;
|
|
chunk__51850_51941 = G__51947;
|
|
count__51851_51942 = G__51948;
|
|
i__51852_51943 = G__51949;
|
|
continue;
|
|
} else {
|
|
var temp__5823__auto___51950 = cljs.core.seq(seq__51849_51940);
|
|
if(temp__5823__auto___51950){
|
|
var seq__51849_51951__$1 = temp__5823__auto___51950;
|
|
if(cljs.core.chunked_seq_QMARK_(seq__51849_51951__$1)){
|
|
var c__5548__auto___51952 = cljs.core.chunk_first(seq__51849_51951__$1);
|
|
var G__51953 = cljs.core.chunk_rest(seq__51849_51951__$1);
|
|
var G__51954 = c__5548__auto___51952;
|
|
var G__51955 = cljs.core.count(c__5548__auto___51952);
|
|
var G__51956 = (0);
|
|
seq__51849_51940 = G__51953;
|
|
chunk__51850_51941 = G__51954;
|
|
count__51851_51942 = G__51955;
|
|
i__51852_51943 = G__51956;
|
|
continue;
|
|
} else {
|
|
var w_51957 = cljs.core.first(seq__51849_51951__$1);
|
|
cljs.core._remove_watch(w_51957,this$__$1);
|
|
|
|
|
|
var G__51958 = cljs.core.next(seq__51849_51951__$1);
|
|
var G__51959 = null;
|
|
var G__51960 = (0);
|
|
var G__51961 = (0);
|
|
seq__51849_51940 = G__51958;
|
|
chunk__51850_51941 = G__51959;
|
|
count__51851_51942 = G__51960;
|
|
i__51852_51943 = G__51961;
|
|
continue;
|
|
}
|
|
} else {
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
if((!((this$__$1.on_dispose == null)))){
|
|
this$__$1.on_dispose(s);
|
|
} else {
|
|
}
|
|
|
|
var temp__5827__auto__ = this$__$1.on_dispose_arr;
|
|
if((temp__5827__auto__ == null)){
|
|
return null;
|
|
} else {
|
|
var a = temp__5827__auto__;
|
|
var n__5616__auto__ = a.length;
|
|
var i = (0);
|
|
while(true){
|
|
if((i < n__5616__auto__)){
|
|
var fexpr__51853_51962 = (a[i]);
|
|
(fexpr__51853_51962.cljs$core$IFn$_invoke$arity$1 ? fexpr__51853_51962.cljs$core$IFn$_invoke$arity$1(this$__$1) : fexpr__51853_51962.call(null,this$__$1));
|
|
|
|
var G__51963 = (i + (1));
|
|
i = G__51963;
|
|
continue;
|
|
} else {
|
|
return null;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.reagent$ratom$IDisposable$add_on_dispose_BANG_$arity$2 = (function (this$,f__$1){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
var temp__5825__auto__ = this$__$1.on_dispose_arr;
|
|
if((temp__5825__auto__ == null)){
|
|
return (this$__$1.on_dispose_arr = [f__$1]);
|
|
} else {
|
|
var a = temp__5825__auto__;
|
|
return a.push(f__$1);
|
|
}
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.cljs$core$IReset$_reset_BANG_$arity$2 = (function (a,newval){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
if(cljs.core.fn_QMARK_(a__$1.on_set)){
|
|
} else {
|
|
throw (new Error(["Assert failed: ","Reaction is read only; on-set is not allowed","\n","(fn? (.-on-set a))"].join('')));
|
|
}
|
|
|
|
var oldval = self__.state;
|
|
(self__.state = newval);
|
|
|
|
a__$1.on_set(oldval,newval);
|
|
|
|
reagent.ratom.notify_w(a__$1,oldval,newval);
|
|
|
|
return newval;
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.cljs$core$ISwap$_swap_BANG_$arity$2 = (function (a,f__$1){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,(function (){var G__51854 = a__$1._peek_at();
|
|
return (f__$1.cljs$core$IFn$_invoke$arity$1 ? f__$1.cljs$core$IFn$_invoke$arity$1(G__51854) : f__$1.call(null,G__51854));
|
|
})());
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.cljs$core$ISwap$_swap_BANG_$arity$3 = (function (a,f__$1,x){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,(function (){var G__51855 = a__$1._peek_at();
|
|
var G__51856 = x;
|
|
return (f__$1.cljs$core$IFn$_invoke$arity$2 ? f__$1.cljs$core$IFn$_invoke$arity$2(G__51855,G__51856) : f__$1.call(null,G__51855,G__51856));
|
|
})());
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.cljs$core$ISwap$_swap_BANG_$arity$4 = (function (a,f__$1,x,y){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,(function (){var G__51857 = a__$1._peek_at();
|
|
var G__51858 = x;
|
|
var G__51859 = y;
|
|
return (f__$1.cljs$core$IFn$_invoke$arity$3 ? f__$1.cljs$core$IFn$_invoke$arity$3(G__51857,G__51858,G__51859) : f__$1.call(null,G__51857,G__51858,G__51859));
|
|
})());
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.cljs$core$ISwap$_swap_BANG_$arity$5 = (function (a,f__$1,x,y,more){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,cljs.core.apply.cljs$core$IFn$_invoke$arity$5(f__$1,a__$1._peek_at(),x,y,more));
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.reagent$ratom$IRunnable$ = cljs.core.PROTOCOL_SENTINEL);
|
|
|
|
(reagent.ratom.Reaction.prototype.reagent$ratom$IRunnable$run$arity$1 = (function (this$){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
(reagent.ratom.flush_BANG_.cljs$core$IFn$_invoke$arity$0 ? reagent.ratom.flush_BANG_.cljs$core$IFn$_invoke$arity$0() : reagent.ratom.flush_BANG_.call(null));
|
|
|
|
return this$__$1._run(false);
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.cljs$core$IWatchable$_notify_watches$arity$3 = (function (this$,old,new$){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
return reagent.ratom.notify_w(this$__$1,old,new$);
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.cljs$core$IWatchable$_add_watch$arity$3 = (function (this$,key,f__$1){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
return reagent.ratom.add_w(this$__$1,key,f__$1);
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.cljs$core$IWatchable$_remove_watch$arity$2 = (function (this$,key){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
var was_empty = cljs.core.empty_QMARK_(self__.watches);
|
|
reagent.ratom.remove_w(this$__$1,key);
|
|
|
|
if((((!(was_empty))) && (((cljs.core.empty_QMARK_(self__.watches)) && ((self__.auto_run == null)))))){
|
|
return this$__$1.reagent$ratom$IDisposable$dispose_BANG_$arity$1(null);
|
|
} else {
|
|
return null;
|
|
}
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.prototype.cljs$core$IDeref$_deref$arity$1 = (function (this$){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
var temp__5827__auto___51964 = self__.caught;
|
|
if((temp__5827__auto___51964 == null)){
|
|
} else {
|
|
var e_51965 = temp__5827__auto___51964;
|
|
throw e_51965;
|
|
}
|
|
|
|
var non_reactive_51966 = (reagent.ratom._STAR_ratom_context_STAR_ == null);
|
|
if(non_reactive_51966){
|
|
(reagent.ratom.flush_BANG_.cljs$core$IFn$_invoke$arity$0 ? reagent.ratom.flush_BANG_.cljs$core$IFn$_invoke$arity$0() : reagent.ratom.flush_BANG_.call(null));
|
|
} else {
|
|
}
|
|
|
|
if(((non_reactive_51966) && ((self__.auto_run == null)))){
|
|
if(self__.dirty_QMARK_){
|
|
var oldstate_51967 = self__.state;
|
|
(self__.state = (self__.f.cljs$core$IFn$_invoke$arity$0 ? self__.f.cljs$core$IFn$_invoke$arity$0() : self__.f.call(null)));
|
|
|
|
if((((self__.watches == null)) || (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(oldstate_51967,self__.state)))){
|
|
} else {
|
|
reagent.ratom.notify_w(this$__$1,oldstate_51967,self__.state);
|
|
}
|
|
} else {
|
|
}
|
|
} else {
|
|
reagent.ratom.notify_deref_watcher_BANG_(this$__$1);
|
|
|
|
if(self__.dirty_QMARK_){
|
|
this$__$1._run(false);
|
|
} else {
|
|
}
|
|
}
|
|
|
|
return self__.state;
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.getBasis = (function (){
|
|
return new cljs.core.PersistentVector(null, 8, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"f","f",43394975,null),cljs.core.with_meta(new cljs.core.Symbol(null,"state","state",-348086572,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"dirty?","dirty?",-419314319,null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"tag","tag",-1290361223),new cljs.core.Symbol(null,"boolean","boolean",-278886877,null),new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"nocache?","nocache?",-1065670978,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"tag","tag",-1290361223),new cljs.core.Symbol(null,"boolean","boolean",-278886877,null)], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"watching","watching",1947648227,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"watches","watches",1367433992,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"auto-run","auto-run",-696035332,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"caught","caught",2084008322,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
|
|
}));
|
|
|
|
(reagent.ratom.Reaction.cljs$lang$type = true);
|
|
|
|
(reagent.ratom.Reaction.cljs$lang$ctorStr = "reagent.ratom/Reaction");
|
|
|
|
(reagent.ratom.Reaction.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
|
|
return cljs.core._write(writer__5311__auto__,"reagent.ratom/Reaction");
|
|
}));
|
|
|
|
/**
|
|
* Positional factory function for reagent.ratom/Reaction.
|
|
*/
|
|
reagent.ratom.__GT_Reaction = (function reagent$ratom$__GT_Reaction(f,state,dirty_QMARK_,nocache_QMARK_,watching,watches,auto_run,caught){
|
|
return (new reagent.ratom.Reaction(f,state,dirty_QMARK_,nocache_QMARK_,watching,watches,auto_run,caught));
|
|
});
|
|
|
|
reagent.ratom.flush_BANG_ = (function reagent$ratom$flush_BANG_(){
|
|
while(true){
|
|
var q = reagent.ratom.rea_queue;
|
|
if((q == null)){
|
|
return null;
|
|
} else {
|
|
(reagent.ratom.rea_queue = null);
|
|
|
|
var n__5616__auto___51969 = q.length;
|
|
var i_51970 = (0);
|
|
while(true){
|
|
if((i_51970 < n__5616__auto___51969)){
|
|
var r_51971 = (q[i_51970]);
|
|
r_51971._queued_run();
|
|
|
|
var G__51972 = (i_51970 + (1));
|
|
i_51970 = G__51972;
|
|
continue;
|
|
} else {
|
|
}
|
|
break;
|
|
}
|
|
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
});
|
|
(reagent.impl.batching.ratom_flush = reagent.ratom.flush_BANG_);
|
|
reagent.ratom.make_reaction = (function reagent$ratom$make_reaction(var_args){
|
|
var args__5755__auto__ = [];
|
|
var len__5749__auto___51973 = arguments.length;
|
|
var i__5750__auto___51974 = (0);
|
|
while(true){
|
|
if((i__5750__auto___51974 < len__5749__auto___51973)){
|
|
args__5755__auto__.push((arguments[i__5750__auto___51974]));
|
|
|
|
var G__51975 = (i__5750__auto___51974 + (1));
|
|
i__5750__auto___51974 = G__51975;
|
|
continue;
|
|
} else {
|
|
}
|
|
break;
|
|
}
|
|
|
|
var argseq__5756__auto__ = ((((1) < args__5755__auto__.length))?(new cljs.core.IndexedSeq(args__5755__auto__.slice((1)),(0),null)):null);
|
|
return reagent.ratom.make_reaction.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5756__auto__);
|
|
});
|
|
|
|
(reagent.ratom.make_reaction.cljs$core$IFn$_invoke$arity$variadic = (function (f,p__51862){
|
|
var map__51863 = p__51862;
|
|
var map__51863__$1 = cljs.core.__destructure_map(map__51863);
|
|
var auto_run = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__51863__$1,new cljs.core.Keyword(null,"auto-run","auto-run",1958400437));
|
|
var on_set = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__51863__$1,new cljs.core.Keyword(null,"on-set","on-set",-140953470));
|
|
var on_dispose = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__51863__$1,new cljs.core.Keyword(null,"on-dispose","on-dispose",2105306360));
|
|
var reaction = reagent.ratom.__GT_Reaction(f,null,true,false,null,null,null,null);
|
|
reaction._set_opts(new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"auto-run","auto-run",1958400437),auto_run,new cljs.core.Keyword(null,"on-set","on-set",-140953470),on_set,new cljs.core.Keyword(null,"on-dispose","on-dispose",2105306360),on_dispose], null));
|
|
|
|
return reaction;
|
|
}));
|
|
|
|
(reagent.ratom.make_reaction.cljs$lang$maxFixedArity = (1));
|
|
|
|
/** @this {Function} */
|
|
(reagent.ratom.make_reaction.cljs$lang$applyTo = (function (seq51860){
|
|
var G__51861 = cljs.core.first(seq51860);
|
|
var seq51860__$1 = cljs.core.next(seq51860);
|
|
var self__5734__auto__ = this;
|
|
return self__5734__auto__.cljs$core$IFn$_invoke$arity$variadic(G__51861,seq51860__$1);
|
|
}));
|
|
|
|
reagent.ratom.temp_reaction = reagent.ratom.make_reaction(null);
|
|
/**
|
|
* Evaluates `f` and returns the result. If `f` calls `deref` on any ratoms,
|
|
* creates a new Reaction that watches those atoms and calls `run` whenever
|
|
* any of those watched ratoms change. Also, the new reaction is added to
|
|
* list of 'watches' of each of the ratoms. The `run` parameter is a function
|
|
* that should expect one argument. It is passed `obj` when run. The `opts`
|
|
* are any options accepted by a Reaction and will be set on the newly created
|
|
* Reaction. Sets the newly created Reaction to the `key` on `obj`.
|
|
*/
|
|
reagent.ratom.run_in_reaction = (function reagent$ratom$run_in_reaction(f,obj,key,run,opts){
|
|
var r = reagent.ratom.temp_reaction;
|
|
var res = reagent.ratom.deref_capture(f,r);
|
|
if((r.watching == null)){
|
|
} else {
|
|
(reagent.ratom.temp_reaction = reagent.ratom.make_reaction(null));
|
|
|
|
r._set_opts(opts);
|
|
|
|
(r.f = f);
|
|
|
|
(r.auto_run = (function (){
|
|
return (run.cljs$core$IFn$_invoke$arity$1 ? run.cljs$core$IFn$_invoke$arity$1(obj) : run.call(null,obj));
|
|
}));
|
|
|
|
reagent.ratom.goog$module$goog$object.set(obj,key,r);
|
|
}
|
|
|
|
return res;
|
|
});
|
|
reagent.ratom.check_derefs = (function reagent$ratom$check_derefs(f){
|
|
var ctx = ({});
|
|
var res = reagent.ratom.in_context(ctx,f);
|
|
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [res,(!((ctx.captured == null)))], null);
|
|
});
|
|
|
|
/**
|
|
* @constructor
|
|
* @implements {cljs.core.IWatchable}
|
|
* @implements {cljs.core.IAtom}
|
|
* @implements {cljs.core.IEquiv}
|
|
* @implements {cljs.core.IReset}
|
|
* @implements {cljs.core.ISwap}
|
|
* @implements {cljs.core.IDeref}
|
|
* @implements {cljs.core.IPrintWithWriter}
|
|
*/
|
|
reagent.ratom.Wrapper = (function (state,callback,changed,watches){
|
|
this.state = state;
|
|
this.callback = callback;
|
|
this.changed = changed;
|
|
this.watches = watches;
|
|
this.cljs$lang$protocol_mask$partition1$ = 114690;
|
|
this.cljs$lang$protocol_mask$partition0$ = 2149613568;
|
|
});
|
|
(reagent.ratom.Wrapper.prototype.cljs$core$IDeref$_deref$arity$1 = (function (this$){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
if(((self__.changed) && ((!((reagent.ratom._STAR_ratom_context_STAR_ == null)))))){
|
|
if(reagent.debug.has_console){
|
|
((reagent.debug.tracking)?reagent.debug.track_console:console).warn(["Warning: ","derefing stale wrap: ",cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([this$__$1], 0))].join(''));
|
|
} else {
|
|
}
|
|
} else {
|
|
}
|
|
|
|
|
|
return self__.state;
|
|
}));
|
|
|
|
(reagent.ratom.Wrapper.prototype.cljs$core$IReset$_reset_BANG_$arity$2 = (function (this$,newval){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
var oldval = self__.state;
|
|
(self__.changed = true);
|
|
|
|
(self__.state = newval);
|
|
|
|
if((!((self__.watches == null)))){
|
|
reagent.ratom.notify_w(this$__$1,oldval,newval);
|
|
} else {
|
|
}
|
|
|
|
(self__.callback.cljs$core$IFn$_invoke$arity$1 ? self__.callback.cljs$core$IFn$_invoke$arity$1(newval) : self__.callback.call(null,newval));
|
|
|
|
return newval;
|
|
}));
|
|
|
|
(reagent.ratom.Wrapper.prototype.cljs$core$ISwap$_swap_BANG_$arity$2 = (function (a,f){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,(f.cljs$core$IFn$_invoke$arity$1 ? f.cljs$core$IFn$_invoke$arity$1(self__.state) : f.call(null,self__.state)));
|
|
}));
|
|
|
|
(reagent.ratom.Wrapper.prototype.cljs$core$ISwap$_swap_BANG_$arity$3 = (function (a,f,x){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,(f.cljs$core$IFn$_invoke$arity$2 ? f.cljs$core$IFn$_invoke$arity$2(self__.state,x) : f.call(null,self__.state,x)));
|
|
}));
|
|
|
|
(reagent.ratom.Wrapper.prototype.cljs$core$ISwap$_swap_BANG_$arity$4 = (function (a,f,x,y){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,(f.cljs$core$IFn$_invoke$arity$3 ? f.cljs$core$IFn$_invoke$arity$3(self__.state,x,y) : f.call(null,self__.state,x,y)));
|
|
}));
|
|
|
|
(reagent.ratom.Wrapper.prototype.cljs$core$ISwap$_swap_BANG_$arity$5 = (function (a,f,x,y,more){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return a__$1.cljs$core$IReset$_reset_BANG_$arity$2(null,cljs.core.apply.cljs$core$IFn$_invoke$arity$5(f,self__.state,x,y,more));
|
|
}));
|
|
|
|
(reagent.ratom.Wrapper.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (this$,other){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
return (((other instanceof reagent.ratom.Wrapper)) && ((((!(self__.changed))) && (((cljs.core.not(other.changed)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(self__.state,other.state)) && (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(self__.callback,other.callback)))))))));
|
|
}));
|
|
|
|
(reagent.ratom.Wrapper.prototype.cljs$core$IWatchable$_notify_watches$arity$3 = (function (this$,old,new$){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
return reagent.ratom.notify_w(this$__$1,old,new$);
|
|
}));
|
|
|
|
(reagent.ratom.Wrapper.prototype.cljs$core$IWatchable$_add_watch$arity$3 = (function (this$,key,f){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
return reagent.ratom.add_w(this$__$1,key,f);
|
|
}));
|
|
|
|
(reagent.ratom.Wrapper.prototype.cljs$core$IWatchable$_remove_watch$arity$2 = (function (this$,key){
|
|
var self__ = this;
|
|
var this$__$1 = this;
|
|
return reagent.ratom.remove_w(this$__$1,key);
|
|
}));
|
|
|
|
(reagent.ratom.Wrapper.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (a,w,opts){
|
|
var self__ = this;
|
|
var a__$1 = this;
|
|
return reagent.ratom.pr_atom(a__$1,w,opts,"Wrapper",new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"val","val",128701612),a__$1.cljs$core$IDeref$_deref$arity$1(null)], null));
|
|
}));
|
|
|
|
(reagent.ratom.Wrapper.getBasis = (function (){
|
|
return new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"state","state",-348086572,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"callback","callback",935395299,null),cljs.core.with_meta(new cljs.core.Symbol(null,"changed","changed",-2083710852,null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"tag","tag",-1290361223),new cljs.core.Symbol(null,"boolean","boolean",-278886877,null),new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"watches","watches",1367433992,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
|
|
}));
|
|
|
|
(reagent.ratom.Wrapper.cljs$lang$type = true);
|
|
|
|
(reagent.ratom.Wrapper.cljs$lang$ctorStr = "reagent.ratom/Wrapper");
|
|
|
|
(reagent.ratom.Wrapper.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
|
|
return cljs.core._write(writer__5311__auto__,"reagent.ratom/Wrapper");
|
|
}));
|
|
|
|
/**
|
|
* Positional factory function for reagent.ratom/Wrapper.
|
|
*/
|
|
reagent.ratom.__GT_Wrapper = (function reagent$ratom$__GT_Wrapper(state,callback,changed,watches){
|
|
return (new reagent.ratom.Wrapper(state,callback,changed,watches));
|
|
});
|
|
|
|
reagent.ratom.make_wrapper = (function reagent$ratom$make_wrapper(value,callback_fn,args){
|
|
return reagent.ratom.__GT_Wrapper(value,reagent.impl.util.make_partial_fn(callback_fn,args),false,null);
|
|
});
|
|
|
|
//# sourceMappingURL=reagent.ratom.js.map
|