This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-07
Channels
- # admin-announcements (54)
- # announcements (1)
- # beginners (145)
- # boot (122)
- # cider (10)
- # cljs-dev (25)
- # cljsrn (20)
- # clojure (173)
- # clojure-art (4)
- # clojure-austria (1)
- # clojure-berlin (3)
- # clojure-germany (1)
- # clojure-nl (2)
- # clojure-russia (117)
- # clojure-switzerland (1)
- # clojure-uk (3)
- # clojurebridge (6)
- # clojurecup (36)
- # clojurescript (218)
- # clojurex (1)
- # core-typed (17)
- # cursive (23)
- # data-science (1)
- # datavis (2)
- # datomic (28)
- # emacs (3)
- # flambo (1)
- # hoplon (28)
- # ldnclj (19)
- # lein-figwheel (2)
- # leiningen (1)
- # luminus (1)
- # off-topic (1)
- # om (158)
- # portland-or (1)
- # re-frame (72)
- # reagent (48)
- # remote-jobs (1)
- # slack-help (7)
@dnolen: the parser impl cljc file needs a jvm exception case on this line: https://github.com/omcljs/om/blob/master/src/main/om/next/impl/parser.cljc#L87 This prevents one from requiring om.next.server
currently with master.
Is there a way to force an entire page refresh/redraw on demand (e.g., on [debounced] resize event])?
I'm rendering a table and there are two unwelcome artifacts on resize (which currently merely incs a counter in app-state
to force a render
): a) if the vertical size is diminished, then the table remains its previously max height even though I'm rendering a [correct] fewer amount of rows in my render and b) if the vertical size is increased, then the newly added row(s) fall outside the existing 'tbody' presumably because React is trying to be smart/efficient and re-use what existing stuff it can. [This causes React to complain about the orphaned rows in the JS console].
I think calling om/add-root!
with the same arguments you used to mount the app originally will force a render. I have figwheel remount the app on reload so that I see any UI changes immediately.
@johanatan: keep an eye out because there'll soon be a way to do it explicitly (https://github.com/omcljs/om/issues/485 )
My read function is called two times with nil
target and :remote
one. I’m not using any remotes, should I somehow disable :remote
target?
is there any performance implications because of this?
I don't think there's a way to disable that
it's just how Om works
if you don't have any remotes it won't do anything
not sure about performance implications but I'd say they're negligible
OK, thanks
@artemyarulin: there will never be any way to control how many times read or mutate gets called
ack, thanks
Trying to understand how to work with remotes. As I understood my send
functions has to call cb
arguments with new data. And this cb then forwards this data to my merge
function? Is it so?
Sorry for the dumb questions
@artemyarulin: Pretty much. merge goes on to call merge-tree, merge-idents and migrate
merge-tree adds the new data to your app state and migrate updates tempids
you probably don't have to provide a custom implementation for merge, just :merge-tree and maybe :migrate
Hm, :merge and :merge-tree are different?
I guess I need :merge-tree in order to merge the new data into the right place in state
hi, I need to use SVG's pattern, but Om doesn't have it (thought React supports it) -- how can I tweak Om to support it for my code ?
(btw, I know about Sablono, but since I need to compose pattern with existing Om code, I can't see a way to use it)
(because Sablono takes vectors but my Om code returns (svg #js {} (rect #js {} etc
@artemyarulin: implementing :merge
means you want to take complete control over how merging happens
if all you want to do is control how the data gets merged using the default db, :merge-tree
is enough
oh, cool, thanks. When do I need to use :merge-idents
?
Cool, it’s clear for me. Thank you!
@anmonteiro: thankyou so much!
How does the :keyfn of factory work? The examples have this line (def person (om/factory Person {:keyfn :name})), Do I basically give it a keyword in my map ?
@dnolen: I may have found a bug in normalization, where recursive joins break other joins. I find it hard to describe. Here's input data, UI (root component omitted) and query result data: https://gist.github.com/Jannis/e16dac5628ca7a0ef229 - note how in the query result, :parent
is broken (a list of idents instead of the actual parent data) in one place but not in the other. It may be intentional and perhaps I'm doing something wrong?
Is there a way to make this kind of thing work (e.g. by making the read function smarter, which currently simply does {:value (om/db->tree query (get st key) st)}
)?
I guess I could treat it as a tree, drop :parent
and instead pass the parent down to children in render
.
That way they could refer to the parent but there would be no cycles in the data itself.
There's no fixed limit for the depth in my case but in reality the data won't be deeper than 3-5 levels.
I'll see if I can find ways to avoid the data loop short-term; there are a few other places where loops exist as well and it might not be as easy there
Am I correct in understanding that IDidUpdate does not get called after the initial render, only after subsequent renders?
correct
https://facebook.github.io/react/docs/component-specs.html#updating-componentdidupdate
componentDidMount
for the initial render
componentDidUpdate
for subsequent ones
is there any docs/examples about server streaming/server push?
@artemyarulin: not yet
just a placeholder in the wiki for now
Yeah, I found it already
But is there API for that, does om support it already?
@tmtwd: can you rephrase?
not that I know of
I'm pretty sure Om will continue to be "A ClojureScript interface to Facebook's React."
@artemyarulin: I believe the API supports it already
personally, I haven't tried it yet, but I imagine it's not difficult
@anmonteiro: OK, I’ll check the source code
I don't think you'll find anything particular to that use case in Om's source
@artemyarulin: streaming isn’t any different from writing send minus the send part
As David keeps saying, Om doesn't do anything, it's up to us to make it do what we want
So, just to clarify - my external code can change atom state and om-next will handle it?
ahh, merge!
function from om
so no you don’t want to do stuff like arbitrary swap!
unless you’re prepared to handle all the boilerplate yourself
Got it, cool. It should be quite easy to implement
Nice, thanks!
Is there explanation about how om/tempid
is supposed to be used with a datomic-based remote?
So far, I've been trying to read om's source code to figure that out. But I am a slow and inept at source code reading.
@paxan: om/tempid
doesn’t really have anything to do with Datomic it’s just a generic thing
is it meant to be playing well with mutation fns that on server side have :tempids { ... }
produced by datomic?
so i need to implement mapping between tempids generated by om on client and resolved tempids produced by datomic, right?
walk the transact entity data using a state atom wrapping a map, everytime you encounter an om tempid replace with a datomic tempid add this mapping to the state atom
when you’re about to return the result back to the client, compute :tempids
for each mutation using :result
of each mutation
I think I understand now, @dnolen. something like that?
(let [conn ...
state ...
tid->otid (atom {})
tx (clojure.walk/postwalk
(pseudo-fn "when you see om/tempid x, replace with datomic/tempid y, and assoc! y->x to tid->otid map")
state)]
(let [datomic-result @(transact conn tx)]
{;; ... result to be returned to client, and:
:tempids (into {} (for [[tid id] (:tempids datomic-result)
:let [otid (@tid->otid tid)]
:when (some? otid)]
[otid id]))}))
Seeking some help with normalization. I tried adding very basic routing to the Components, Identity, and Normalization tutorial. I split :list/one and :list/two into two separate routes, and the root component only includes in its query the query for the current route. So, assuming we start with the route :route-1, the first query looks like [:session/route {:list/one [:name :points :age]}]. This renders the initial page just fine. But when you try to nav to :route-2, the :list/two data isn't normalized. This is because the data is only normalized when we first call add-root!, and at that time, Om doesn't know anything about the :list/two query. I do not know how to either 1) normalize all the data upfront while preventing over-fetching or 2) normalize the data again every time the root query changes. Here's a gist with the differences from the tutorial marked: https://gist.github.com/tomconnors/c1cceaae84fd059e37a3
if you have a bunch client side information normalize this stuff yourself if the default behavior can’t take care of it for you
@dnolen: So in this situation I would just want to normalize the data myself before add-root!
ing?
ah, I see, I can just use tree->db
along with a query that unionizes the queries of every possible route. cool!
hey david have you poked around with how react native mounted components behave?
@johannjohann: if that’s directed at me, no I haven’t looked at React Native at all
totes understand
but PRs are welcome to make it work, whatever the issues are I can’t imagine they are very significant
there is a channel #C0E1SN0NM and people there discuss RN + Om-next sometimes
ouu very nice
here the example https://github.com/mfikes/auto-completion
@dnolen: I was able to get routing + normalization working based on your earlier advice, but now full-query
is not working for any components other than the RootView. Looking at the indexer's :class-path->query map, the expected path (om-tutorial.core/RootView om-tutorial.core/RouteTwo om-tutorial.core/Person) is missing, but (om-tutorial.core/RootView om-tutorial.core/Person) is present. Why would the in-between component be missing?
if RouteTwo actually has a query and it wasn’t indexed correctly it’s because you’re doing something that’s not supported