Closed xfsnowind closed 7 years ago
Is it supposed to be this?
I also tried om-next-demo, and print out the next-props
in shouldComponentUpdate
in component Todos
, it shows:
{"test"
#js {:omcljs$value #object[om.next.OmProps], :omcljs$instrument nil, :omcljs$shared nil, :omcljs$path [], :omcljs$reconciler #om.next.Reconciler{:config {:pathopt false, :id-key nil, :instrument nil, :merge-ident #object[Function "function (a, b, c, d) {
return cljs.core.update_in.cljs$core$IFn$_invoke$arity$4(b, c, cljs.core.merge, d);
}"], :merge-sends #object[Function "function (a, b) {
return cljs.core.merge_with.cljs$core$IFn$_invoke$arity$variadic(cljs.core.into, cljs.core.array_seq([a, b], 0));
}"], :remotes [:remote], :migrate #object[Function "function (a) {
for (var b = [], c = arguments.length, d = 0;;) {
if (d < c) {
b.push(arguments[d]), d += 1;
} else {
break;
}
}
switch(b.length) {
case 3:
return om.next.default_migrate.cljs$core$IFn$_invoke$arity$3(arguments[0], arguments[1], arguments[2]);
case 4:
return om.next.default_migrate.cljs$core$IFn$_invoke$arity$4(arguments[0], arguments[1], arguments[2], arguments[3]);
default:
throw Error([cljs.core.str("Invalid arity: "), cljs.core.str(b.length)].join(""));;
}
}"], :history #object[om.next.cache.Cache], :state #object [cljs.core.Atom {:val {:todos/list [[:todos/by-id 17592186045418] [:todos/by-id 17592186045419]], :todos/by-id {17592186045418 {:db/id 17592186045418, :todo/completed true, :todo/title "Get milk"}, 17592186045419 {:db/id 17592186045419, :todo/completed false, :todo/title "Walk dog"}}, :om.next/tables #{}, todo/update {:keys [[:todos/by-id 17592186045418]], :result {:tempids {}}}}}], :merge #object[Function "function (a, b, c, d) {
return new cljs.core.PersistentArrayMap(null, 3, [cljs.core.cst$kw$keys, cljs.core.into.cljs$core$IFn$_invoke$arity$3(cljs.core.PersistentVector.EMPTY, cljs.core.remove.cljs$core$IFn$_invoke$arity$1(cljs.core.symbol_QMARK_), cljs.core.keys(c)), cljs.core.cst$kw$next, om.next.merge_novelty_BANG_(a, b, c, d), cljs.core.cst$kw$tempids, cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(cljs.core.merge, cljs.core.PersistentArrayMap.EMPTY, cljs.core.map.cljs$core$IFn$_invoke$arity$2(cljs.core.comp.cljs$core$IFn$_invoke$arity$2(cljs.core.cst$kw$tempids,
cljs.core.second), cljs.core.filter.cljs$core$IFn$_invoke$arity$2(cljs.core.comp.cljs$core$IFn$_invoke$arity$2(cljs.core.symbol_QMARK_, cljs.core.first), c)))], null);
}"], :shared-fn nil, :parser #object[l "function (a, b, c) {
switch(arguments.length) {
case 2:
return m.call(this, a, b);
case 3:
return n.call(this, a, b, c);
}
throw Error("Invalid arity: " + arguments.length);
}"], :ui->props #object[Function "function (a, b) {
var c = null != a && (a.cljs$lang$protocol_mask$partition0$ & 64 || a.cljs$core$ISeq$) ? cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map, a) : a, d = cljs.core.get.cljs$core$IFn$_invoke$arity$2(c, cljs.core.cst$kw$parser), e = cljs.core.get.cljs$core$IFn$_invoke$arity$2(c, cljs.core.cst$kw$pathopt), f = function() {
if (e) {
var a = null != b ? b.om$next$Ident$ ? !0 : !1 : !1;
return a ? om.next.iquery_QMARK_(b) : a;
}
return e;
}() ? function() {
var a = om.next.ident(b, om.next.props(b));
return cljs.core.get.cljs$core$IFn$_invoke$arity$2(function() {
var e = new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.PersistentArrayMap.fromArray([a, om.next.get_query(b)], !0, !1)], null);
return d.cljs$core$IFn$_invoke$arity$2 ? d.cljs$core$IFn$_invoke$arity$2(c, e) : d.call(null, c, e);
}(), a);
}() : null;
if (null != f) {
return f;
}
f = om.next.full_query.cljs$core$IFn$_invoke$arity$1(b);
if (null == f) {
return null;
}
var g = cljs.core.system_time(), f = d.cljs$core$IFn$_invoke$arity$2 ? d.cljs$core$IFn$_invoke$arity$2(c, f) : d.call(null, c, f), h = cljs.core.system_time(), k = cljs.core.cst$kw$logger.cljs$core$IFn$_invoke$arity$1(c);
cljs.core.truth_(k) && (g = h - g, 16 < g && (g = [cljs.core.str(b), cljs.core.str(" query took "), cljs.core.str(g), cljs.core.str(" msecs")].join(""), goog.log.warning(k, g)));
return cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(f, om.next.path(b));
}"], :logger nil, :indexer #om.next.Indexer{:indexes #object [cljs.core.Atom {:val {:class->components {todomvc.core/Todos #{#object[todomvc.core.Todos]}, todomvc.item/TodoItem #{#object[todomvc.item.TodoItem] #object[todomvc.item.TodoItem]}}, :ref->components {[:todos/by-id 17592186045418] #{#object[todomvc.item.TodoItem]}, [:todos/by-id 17592186045419] #{#object[todomvc.item.TodoItem]}}, :prop->classes {:todos/list #{todomvc.core/Todos}, :db/id #{todomvc.item/TodoItem}, :todo/editing #{todomvc.item/TodoItem}, :todo/completed #{todomvc.item/TodoItem}, :todo/title #{todomvc.item/TodoItem}}, :class-path->query {[todomvc.core/Todos] #{[[{:todos/list [:db/id :todo/editing :todo/completed :todo/title]}] nil]}, [todomvc.core/Todos todomvc.item/TodoItem] #{[[:db/id :todo/editing :todo/completed :todo/title] {:l [:todos/list], :pnodes [[{:todos/list [:db/id :todo/editing :todo/completed :todo/title]}] {:todos/list [:db/id :todo/editing :todo/completed :todo/title]} [:todos/list [:db/id :todo/editing :todo/completed :todo/title]]], :ppath {:l [], :pnodes [[{:todos/list [:db/id :todo/editing :todo/completed :todo/title]}] {:todos/list [:db/id :todo/editing :todo/completed :todo/title]}], :ppath {:l [], :pnodes [[{:todos/list [:db/id :todo/editing :todo/completed :todo/title]}]], :ppath nil, :r nil}, :r nil}, :r nil}]}}}}], :extfs {:index-component #object[Function "function (a, b) {
return a;
}"], :drop-component #object[Function "function (a, b) {
return a;
}"], :ref->components #object[Function "function (a, b) {
return null;
}"]}}, :root-unmount #object[Function "function (a) {
return ReactDOM.unmountComponentAtNode(a);
}"], :send #object[Function "function (b, c) {
var d = null != b && (b.cljs$lang$protocol_mask$partition0$ & 64 || b.cljs$core$ISeq$) ? cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map, b) : b, e = cljs.core.get.cljs$core$IFn$_invoke$arity$2(d, cljs.core.cst$kw$remote);
return goog.net.XhrIo.send(a, function(a, b, d) {
return function(a) {
a = cognitect.transit.read(cognitect.transit.reader.cljs$core$IFn$_invoke$arity$1(cljs.core.cst$kw$json), this.getResponseText());
return c.cljs$core$IFn$_invoke$arity$1 ? c.cljs$core$IFn$_invoke$arity$1(a) : c.call(null, a);
};
}(b, d, e), "POST", cognitect.transit.write(cognitect.transit.writer.cljs$core$IFn$_invoke$arity$1(cljs.core.cst$kw$json), e), {"Content-Type":"application/transit+json"});
}"], :shared nil, :merge-tree #object[Function "function (a, b) {
return cljs.core.map_QMARK_(a) ? cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.array_seq([a, b], 0)) : b;
}"], :optimize #object[Function "function (a) {
return cljs.core.sort_by.cljs$core$IFn$_invoke$arity$2(om.next.depth, a);
}"], :root-render #object[Function "function (a, b) {
return ReactDOM.render(a, b);
}"], :normalize true, :prune-tree #object[Function "function (a, b, c) {
a = function() {
var a = cljs.core.PersistentArrayMap.EMPTY;
return cljs.core.atom.cljs$core$IFn$_invoke$arity$1 ? cljs.core.atom.cljs$core$IFn$_invoke$arity$1(a) : cljs.core.atom.call(null, a);
}();
b = function e(a, b, c) {
var k = cljs.core.cst$kw$component.cljs$core$IFn$_invoke$arity$1(cljs.core.meta(a)), l = null != k && om.next.has_error_QMARK_(b) ? cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$2(c, function(a) {
return function(c) {
return cljs.core.update_in.cljs$core$IFn$_invoke$arity$4(c, new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [om.next.ident(a, b)], null), cljs.core.fnil.cljs$core$IFn$_invoke$arity$2(cljs.core.conj, cljs.core.PersistentHashSet.EMPTY), cljs.core.cst$kw$om$next_SLASH_error.cljs$core$IFn$_invoke$arity$1(b));
};
}(k)) : null, m = null == l ? cljs.core.PersistentArrayMap.EMPTY : null;
if (cljs.core.vector_QMARK_(a)) {
if (cljs.core.vector_QMARK_(b)) {
return cljs.core.into.cljs$core$IFn$_invoke$arity$3(cljs.core.PersistentVector.EMPTY, cljs.core.map.cljs$core$IFn$_invoke$arity$1(function(b, g, k) {
return function(b) {
return e(a, b, c);
};
}(k, l, m)), b);
}
for (var n = cljs.core.seq(a), p = m;;) {
if (null != n) {
var q = cljs.core.first(n), r = function() {
var a = om.next.expr__GT_key(q);
return om.next.unique_ident_QMARK_(a) ? cljs.core.first(a) : a;
}(), t = cljs.core.get.cljs$core$IFn$_invoke$arity$2(b, r);
if (om.next.union_QMARK_(q)) {
var u = om.next.join_key(q), v = om.next.join_value(q), w = cljs.core.cst$kw$component.cljs$core$IFn$_invoke$arity$1(cljs.core.meta(v)), r = cljs.core.vector_QMARK_(t) ? cljs.core.into.cljs$core$IFn$_invoke$arity$3(cljs.core.PersistentVector.EMPTY, cljs.core.map.cljs$core$IFn$_invoke$arity$1(function(a, b, f, g, k, l, m, n, p, q, r) {
return function(a) {
return e(cljs.core.get.cljs$core$IFn$_invoke$arity$2(g, cljs.core.first(om.next.ident(k, a))), a, c);
};
}(n, p, u, v, w, q, r, t, k, l, m)), t) : e(cljs.core.get.cljs$core$IFn$_invoke$arity$2(v, cljs.core.first(om.next.ident(w, t))), t, c), n = cljs.core.next(n), p = null == p ? null : cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(p, u, r)
} else {
cljs.core.truth_(om.next.join_QMARK_(q)) ? (u = om.next.join_key(q), v = om.next.join_value(q), r = e(v, t, c), n = cljs.core.next(n), p = null == p ? null : cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(p, u, r)) : cljs.core.map_QMARK_(t) && om.next.has_error_QMARK_(t) ? (cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$2(c, function(a, c, e, f, h, k, l, m) {
return function(a) {
return cljs.core.update_in.cljs$core$IFn$_invoke$arity$4(a, new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [function() {
var a = null == k ? null : om.next.ident(k, b);
return cljs.core.truth_(a) ? a : f;
}()], null), cljs.core.fnil.cljs$core$IFn$_invoke$arity$2(cljs.core.conj, cljs.core.PersistentHashSet.EMPTY), cljs.core.cst$kw$om$next_SLASH_error.cljs$core$IFn$_invoke$arity$1(h));
};
}(n, p, q, r, t, k, l, m)), n = cljs.core.next(n), p = null) : (n = cljs.core.next(n), p = null == p ? null : cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(p, r, t));
}
} else {
return p;
}
}
} else {
return null;
}
}(c, b, a);
return new cljs.core.PersistentArrayMap(null, 2, [cljs.core.cst$kw$tree, b, cljs.core.cst$kw$errors, cljs.core.deref.cljs$core$IFn$_invoke$arity$1 ? cljs.core.deref.cljs$core$IFn$_invoke$arity$1(a) : cljs.core.deref.call(null, a)], null);
}"]}, :state #object [cljs.core.Atom {:val {:normalized true, :remove #object[Function "function () {
cljs.core.remove_watch(cljs.core.cst$kw$state.cljs$core$IFn$_invoke$arity$1(e.config), cljs.core.truth_(c) ? c : g);
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$2(e.state, function(a, b, c, d, e, f) {
return function(a) {
return cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(a, cljs.core.cst$kw$target), cljs.core.cst$kw$render), cljs.core.cst$kw$root), cljs.core.cst$kw$remove);
};
}(a, b, d, f, g, h));
return null == c ? null : cljs.core.cst$kw$root_DASH_unmount.cljs$core$IFn$_invoke$arity$1(e.config).call(null, c);
}"], :queue [], :sends-queued false, :queued-sends {}, :queued false, :render #object[Function "function () {
var d = om.next.get_query(function() {
var a = cljs.core.deref.cljs$core$IFn$_invoke$arity$1 ? cljs.core.deref.cljs$core$IFn$_invoke$arity$1(c) : cljs.core.deref.call(null, c);
return cljs.core.truth_(a) ? a : b;
}());
if (null != d && !cljs.core.vector_QMARK_(d)) {
throw Error([cljs.core.str("Assert failed: "), cljs.core.str("Application root query must be a vector"), cljs.core.str("\n"), cljs.core.str(cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.array_seq([cljs.core.list(cljs.core.cst$sym$or, cljs.core.list(cljs.core.cst$sym$nil_QMARK_, cljs.core.cst$sym$sel), cljs.core.list(cljs.core.cst$sym$vector_QMARK_, cljs.core.cst$sym$sel))], 0)))].join(""));
}
if (null != d) {
var f = om.next.to_env(e.config), d = cljs.core.cst$kw$parser.cljs$core$IFn$_invoke$arity$1(e.config).call(null, f, d);
return cljs.core.empty_QMARK_(d) ? null : a(d);
}
return a(function() {
var a = cljs.core.cst$kw$state.cljs$core$IFn$_invoke$arity$1(e.config);
return cljs.core.deref.cljs$core$IFn$_invoke$arity$1 ? cljs.core.deref.cljs$core$IFn$_invoke$arity$1(a) : cljs.core.deref.call(null, a);
}());
}"], :root #object[todomvc.core.Todos], [:sends-queued] true, :t 3, :target #object[HTMLElement [object HTMLElement]]}}]}, :omcljs$depth 0, :omcljs$parent nil, :children nil}}
Checked the source code, the next-props
is wrapped with some other information and the function shouldComponentUpdate is also rewritten, think it's my own mistake.
I tried to print the next-props in componentWillReceiveProps, it's the data I expected. but next-props in shouldComponentUpdate is the metadata (seems like):, check the below informations: