What is the query syntax to read from the root of the application state using a parameterized join query from a deeply nested component? Links (https://github.com/omcljs/om/wiki/Thinking-With-Links%21) only seem to be appropriate for simple ident queries. Here is the query that I am want to be read from the root
'[({:hosting-service [:org]} {:url "<https://www.squarespace.com>"})]
i believe links have to start with an ident (two element vector), there are some more query examples in the tests:
https://github.com/omcljs/om/blob/master/src/test/om/next/next_test.clj#L418
@danvingo thanks, the following seems to work
'[({[:hosting-service _] [:org]} {:url "<https://www.squarespace.com>"})]
np, i've actually never seen an example like that, what is this query returning?
the url of an org that's embedded in a hosting service?
The query returns the hosting provider info of any site based on the URL that is passed to it
ah, so url is the param?
yes
nice, very cool
🙂
Has anyone worked on pubsub via Om yet? I'm thinking through what you'd need to do. I think you'd want a send
that received the entire root query each time it changed, rather than just a subset of it, which is what a send
normally gets if a portion of the UI tree changes its query.
That is, you'd want the entire root query so you could diff it against the last one you saw and decide what to subscribe to and what to unsubscribe from
Alternatively, Om could take responsibility for doing the diffing and give the send
the diff
@peeja I implemented a similar approach partially in a project. There, we also subscribe with the root query and push updates to the query to the subscription service whenever it changes. That by itself is probably the easiest part – the trickier part is keeping track of which query (or partial query) of which clients are interested in which parts of the remote db. We got as far as distinguishing between queries for particular data (i.e., parameterized with a specific db record ID such as a specific user ID) or for a collection of data (e.g. all users, kind of like wildcards). And then you’d have to index all client queries smartly, monitor the db for changes, match client queries against these changes and push the right things to the right clients. I think that’s much harder than obtaining the root query. 😉
@peeja have you seen this clever om/datascript/datomic pub sub (using sse): https://github.com/madvas/todomvc-omnext-datomic-datascript
I want to reset! my om.next state (its a datascript db) but om.next no longer likes it No protocol method IWithMeta.-with-meta defined for type cljs.core/Atom
Any work arounds?
nm
In om.next, should ids that have been updated from tempids to real ids trigger a rerender?
nevermind, it definitely does trigger a rerender in some parts, so I’m obviously doing something wrong
Is there a way to pass arguments when defining (not instantiating or creating) a component that would have that argument as a static property? Ie. is it possible to have
(defui MyComponent
static
(aaa [_] something-dynamic)
)
Where something-dynamic
is defined somewhere else in the code?not sure if it's what you're looking for
has anyone implemented IO/network retries in om.next and how did you go about?