This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-28
Channels
- # admin-announcements (1)
- # aws (2)
- # beginners (21)
- # boot (28)
- # braid-chat (1)
- # cider (51)
- # cljs-edn (7)
- # cljsjs (35)
- # cljsrn (2)
- # clojure (85)
- # clojure-chicago (7)
- # clojure-czech (1)
- # clojure-gamedev (3)
- # clojure-poland (2)
- # clojure-russia (80)
- # clojure-sanfrancisco (1)
- # clojure-uk (5)
- # clojurebridge (9)
- # clojurescript (68)
- # cursive (29)
- # datomic (23)
- # emacs (2)
- # hoplon (94)
- # jobs-discuss (15)
- # juxt (2)
- # liberator (2)
- # luminus (16)
- # mount (12)
- # off-topic (7)
- # om (57)
- # onyx (58)
- # proton (10)
- # re-frame (9)
- # reagent (38)
- # remote-jobs (2)
- # rum (12)
- # untangled (136)
Stupid beginner question, moving from OM to OM Next, having some trouble grasping how to manage remotes. For mutations (e.g. User Up-Votes something, ) Do I need to use remotes, or can I define a mutation and use my own logic in the mutation to push the change up to the server.
@dimiter: a mutator can list a remote or remotes it’s syncing with, than the :send
function defined in reconciler will handle the request. You can do anything you want in a mutator, but remote synchronization and updates are supposed to be done in send
, that’s how I've seen it in every tutorial so far. I think it’s a good convention
I’m a bit confused about updating app state from remote. I’ve made a simulated a remote which responds after some delay on a modified code from https://github.com/omcljs/om/wiki/Components,-Identity-&-Normalization. I simply put random values for age and points and called (cb (rewrite ...))
. But the view is not updated although the :person/by-name
referred by ident changed, the generated values are rendered only after the next transact. This is the changed code:
I certainly have incorrect expectations about app state updates. I’ve seen watches on atoms in the om-next code and thought that changes on keys referred by indent will queue components to re-render. It’s obviously not so. How can I reach that updates coming from a remote will be rendered?
I'm trying to create more dynamic queries with alpha34, so I've got components that change with om/props
but the reads sent with my remote mutations are not up to date.
Does it makes sense for queries to depend on a component's props? For example: anmonteiro's subquery routing example calls (om/props this)
(I use a similar strategy).
Then is it a bug that we transform reads in (om/transact! ...)
before mutations has occurred in (om/transact* ...)
?
Shouldn't we want to transform our reads after the parser has executed the mutations, before calling gathering-sends?
Does anyone has a working example of a more realistic application? With routing remote reads, etc
quick question for Om Now: I have a form containing a button and it is doing a form submit when I click the button. What should I do in onClick to stop that (or in onSubmit on the form element?)
given:
{:people/by-id
{1 {:person/name "Sally", :person/age 33},
2 {:person/name "Jesse", :person/age 43},
3 {:person/name "Bo", :person/age 13}}}
how do I query only the :person/name
field for all people/by-id
?
I thought it was simply: [{[:people/by-id _] [:person/name]}]
but that returns {:people/by-id {}}
and [{[:people/by-id _] [*]}]
gets me the entire structure.Does anyone has a working example of a more realistic application? With routing remote reads, etc
@jplaza one I looked at with client/server remote routing https://github.com/juxt/edge/blob/bikes/src/edge/webserver.clj from article https://juxt.pro/blog/posts/course-notes-2.html/
devth: there is no "query for all people/by-id
". [:k _]
is meant to refer to a top-level property on the app state, not an entire table
say e.g. {:app/all-people [[:person/by-id 1] ...]}
in your app state, then [{:app/all-people [:person/name]}]
makes sense
tomjack: you're saying db->tree can't do it on its own and I have to implement some custom read?
i was just playing with https://awkay.github.io/om-tutorial/#!/om_tutorial.D_Queries/ident-based-queries and trying to figure out how to get all the :person/name
s.
Right, there is nothing in the query language designated to mean "everything with this ident key", so db->tree won't really do what you want
bear in mind that the part of the tutorial you’re looking at is focused specifically on the task of looking things up by ident, so it doesn’t have the full data set you’d normally find in a working UI
Normally if you wanted a list of names, you’d have a top-level entry somewhere with a vector of the idents of the people you’re interested in.
then you’d just do a join to get the names
Yeah, I would consider adjusting the state by just putting all the people under a top-level entry like that
i see. seems a little weird that I can just sloppily specify my query to be [[:people/by-id _] [*]]
and get what i need (and more).
i think i've been avoiding creating custom read functions. i just want db->tree to give me everything i need. because read functions all end up looking pretty similar.
i probably need to embrace writing very-similar-looking read fns everywhere. i just don't get it yet.
I’m a bit confused about updating app state from remote. I’ve made a simulated a remote which responds after some delay on a modified code from https://github.com/omcljs/om/wiki/Components,-Identity-&-Normalization. I simply put random values for age and points and called (cb (rewrite ...))
. But the view is not updated although the :person/by-name
referred by ident changed, the generated values are rendered only after the next transact. This is the changed code:
I don’t understand why the component is not changed, or queued for rerender after the :persons/by-id
entries were changed. I’ve seen watches on atoms in the om-next code and thought that changes on keys referred by indent will queue components to re-render. It’s obviously not so. How can I reach that updates coming from a remote will be rendered?
@fifigyuri: The factory on the person ui, you map person to the symbol 'list' that should contain :name, but are you passing :name from root to ListView, or try querying :name from Root? Just throwing ideas.
ps. watch out for using clojure.core variable names for local variables, maybe you are aware of course.
@hlolli: the confusing part for me is that this code just adds the :remote
to the mutator. The original tutorial example is increasing the value, here I simply make an update after some delay. The re-rendering happens only after the next transact!, so the app-state is updated but the component re-rendering does not follow
thanks for the idea, but the original code has it the same way :name
is queued from the Person
there too
Haven't done this tutorial, I've had there rerendering problems all too often. Usually something with IQuery that was forgotten or overestimated. Try printing (om/props this) from Root down to persons, to be sure that you are getting the values passed trough and they are being queried.
They get through, as I mentioned they get re-rendered on the next transact!
so the queries are fine, but I do not understand what triggers queuing the component to re-render. btw. that tutorial revealed me the concept of idents, good tutorial, just hit this problem 😞
for remote mutations with idents (and it is not a tempid) - should the server treat that as an upsert or an update?
fifigyuri: have you seen https://github.com/omcljs/om/wiki/Om-Next-FAQ#why-is-my-component-not-rerendered-after-transact ?
since you're doing (transact! this ...) in a Person, with no reads given in your tx, only that Person will rerender
or not the usual version of that problem. but related. there needs to be something in the query you pass back to cb which causes the rerender
I'd look for :send
in next.cljs to find the relevant spots. in the case you're hitting (through send!
in Reconciler, I think?) only the keys of the delta determine what gets queued
so my snippet has a tree with the idents as keys, with an ad-hoc query which matches that tree