@peeja sorry. I mean if I change the code in initLocalState I want the component to re-mount.
@denik Oh, does it not? It does for me.
In my app, my components lose local state when Figwheel uses that code to reload, and they get whatever's in init-state
Hi guys, I've been dipping my toe into om.next for the last few months and - while I've been able to get things working - I'm pretty sure I'm effectively hacking my way around some blind-spots I have with how I'm supposed to be using it and, now I'm stepping up my usage, I'd like to know how to do it properly
My current problem centres around data distribution across the app. I'm building a set of dashboards that pull data from a remote. The data is live and so needs to be refreshed at regular intervals. I have a component at the root to manage this, and the UI tree instantiates view components that require some subset of data from the root store. What I'm unsure of is - when a new view component is instantiated, what's the correct way to communicate to the manager that it needs to fetch more data from the root (and what that data needs to be)?
Specifically - mutate? set-query? via a channel?
I think we all feel the way you do, at least I do. I think it's whatever works for you. FYI, transact!
can be used to trigger reads as well as mutations.
You could (transact! this [:root/query-fragment])
some query fragment.
Good to know I'm not alone, at least π
Yes - currently using transact, but within the manager component (via a channel), rather than the views (there were ordering issues otherwise)
I don't think there is anything inherently wrong with channels either, it depends what you discover to be easier and more maintainable.
If you settle on any good patterns, I'm sure we'll all be interested to hear about them.
How are you passing the channels around? With :shared
?
Currently it's just stored in a global variable (didn't seem worth the investment in something more detailed yet - still not sure if it's the solution I'll stick with) but would probably move to :shared if it sticks around
Is it possible to call om/ident
server-side?
I would think that would be possible if your components is written in cljc
I can call the instantiated component, but it looks like the class is backed by AFunction$1
which I canβt call ident
on.
@carter.andrewj You may be better off using a separate remote for your live data and then force
ing that remote from a transact!
: https://github.com/omcljs/om/wiki/Documentation-(om.next)#force
By using a separate remote, you can leave it up to the parser to decide which data is live
Then you can transact!
to re-read the entire root query, but because you've forced a specific remote, only the parts that the parser says should be sent to the live remote will actually be fetched
Interesting - is there any more documentation on that with examples, etc...?
(Somewhat reluctant to unpick so much code without knowing where I hope to end up)
Not that I know of. But AFAIK there's no particular pattern for this that would be documented; I just made that up in response to your question.
Is it possible to have separate merge! fns for each remote...?
Okay - and another one π - if I have a query [(:data {:sources ?sources}) :things :stuff]
which gets rolled into the query of a parent component, can I still have a separate read method for :data, :things and :stuff? I can't figure out what the reason would be for not allowing this - but (unless they're keys in the root component), it seems not to be possible. Am I just cocking up somewhere? Or do nested queries like this not work by design?
Where is the best place to override the dynamic var om/*raf*
? om/*raf*
is called inside callbacks, so binding the new value around om/add-root
and other calls to om
don't appear to preserve the overriding binding.
@bnoguchi you may have to just (set! om/*raf* ...)
if you want it globally
Got it, thanks!
@anmonteiro Thank you very much for your (and Mike) presentation on "teleport testing" is great! I was looking for a way to take devcards to the next level for webgl game dev with om/datomic and you gave me lots of great ideas π
@carter.andrewj in order to have your child component's individual parse methods called, your parent's parse method would need to call the parser again on the child's query
@thosmos can that be done? Is there a standard way of doing that or would I be destructuring/restructuring the ast?
@sineer awesome! thanks
@carter.andrewj the parser
and the query
are available at the environment