This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-01-13
Channels
- # admin-announcements (6)
- # beginners (51)
- # boot (164)
- # braid-chat (49)
- # cider (10)
- # clara (17)
- # cljs-dev (13)
- # cljsjs (51)
- # cljsrn (10)
- # clojars (42)
- # clojure (195)
- # clojure-bangladesh (102)
- # clojure-berlin (8)
- # clojure-canada (1)
- # clojure-chicago (19)
- # clojure-colombia (4)
- # clojure-denmark (6)
- # clojure-russia (15)
- # clojure-ukraine (7)
- # clojurescript (257)
- # code-reviews (10)
- # community-development (292)
- # core-async (13)
- # datomic (26)
- # dirac (4)
- # dunaj (5)
- # dysphemism (5)
- # events (21)
- # funcool (15)
- # hoplon (115)
- # instaparse (31)
- # ldnclj (15)
- # mori-fork (43)
- # mount (5)
- # off-topic (18)
- # om (195)
- # onyx (13)
- # proton (9)
- # re-frame (11)
- # reagent (44)
- # slack-help (14)
- # slackpocalypse (1)
- # spacemacs (10)
- # yada (23)
om.next newbie question: Can anyone point me in the right direction for doing updates for aggregate components? Am confused as to how to get an additional component to sum (and update) up multiple pieces of the app state. https://github.com/featheredtoast/hello-om-next/blob/master/src/cljs/hello2/core.cljs
--sample provided is my attempts at getting something to display a running total of all counters. I am able to update state for the aggregate provided by including ':counter' in the om/transact! but that appears to also re-render all other counter components as well. I'm curious as to how you guys would deal with this. Would I hold calculated values in the app state as well, and re-calculate inside the transaction? Making progress on understanding om and its models, but maybe not 'getting' it just yet.
I’m trying to work out why my (child) component ends up reading it’s own local query
, rather than using its ident
. The component in question is in a react native data-source, in a ListView. full-query
doesn’t seem to use ident
, and returns the component’s local query so I think I’m mis-understanding how this should be working.
Hi all: I seem unable to send to remotes from anything but a root query. I encountered this in my own experiments, but I can reproduce the problem by making a very minor modification to the working AutoCompleter tutorial. If I add a very trivial Root
component (line 77:84) and a very trivial matching read
(line 31:33), the :send
function does not get invoked for the child autocomplete. Here is the sample code: https://gist.github.com/zalky/573d2eb12ae3f6fcb2d3.
@juhoteperi: thanks for your help yesterday, turns out I needed to bump Om to alpha 28 to get advanced optimizations to work. Also, understanding how CLJSJS deps work is nice
@zalky: it's true. I will hit the Root component first and send the query right there. But the thing is you can provide additional {:value }
to get the cached value.
Can someone explain to me how (increment)
turns to ’increment
symbol in this example? https://github.com/omcljs/om/wiki/Quick-Start-(om.next)#components-with-queries--mutations
Yes, it’s quoted. I believe I’m really missing something but why can’t we just write (om/transact! this '[increment])
? (I have tried that and it causes error)
‘app/increment
here makes sense to me but it’s a little different with multi-method https://github.com/omcljs/om/wiki/DataScript-Integration-Tutorial#integrating-datascript
(om/transact! this
`[(app/increment ~entity)])
I think that has to do with the query syntax the parser expects. you can see the mutation syntax in the examples here https://awkay.github.io/om-tutorial/#!/om_tutorial.D_Queries
@hugod https://gist.github.com/geraldodev/fd6c61eac7ab4b37c616 I ended up with the entire state on nested component, and figured that was because (get-in {} nil) returns the entire thing. also I was caught by the fact that if a nested component has a value and afterwards its read function returns nil the value remain untouched , so what I really needed was to return an empty map, so I made get-in-link.
@dnolen: something came to mind relating to tempids: it seems to me that, due to how the reconciler expects an :id-key
, you can only ever have one entity in an Om Next app merging tempids successfully
(with the provided default implementations, that is)
@anmonteiro: if you mean a tempid can only become one real ident - yes
more, if you normalize your state in the manner that you use in most tutorials (have an :id
key in the state, but normalize it to e.g. [:person/by-id :id]
), it won't get properly merged
because if your reconciler's :id-key
is :person/by-id
, the merge will write a new key :person/by-id
in the, say, Person
entity, and the tempid will still be there in the original :id
key
@anmonteiro: that’s not how the merge ident logic is supposed to work - could be a bug or you are reading it wrong
I've tried it with a simple example
@dnolen: right, I'll play with it again given this new information, thanks for clearing it up
@anmonteiro: still I’m suprised it’s not handled by this - https://github.com/omcljs/om/blob/master/src/main/om/next.cljs#L1621
@dnolen: not sure we're talking about the same thing, but I need to dig deeper before I can confirm any suspicions
@anmonteiro: oh ...
will only have time later, so I'll get back to you on that
@dnolen: that makes much more sense
and that was indeed my first approach when I was trying this out
I either couldn't make it work because I was doing it wrong, or there's some subtle bug. I'll confirm it later today and let you know
(most probably something wrong on my part, but still...)
@anmonteiro: we don’t have an :id-key
test - happy to have one that confirms this thing actually works
@dnolen: dully noted
unless i’m misunderstanding something that’s exactly how my sample worked for tempids @anmonteiro: https://github.com/akmiller78/tut-omnext-tempids/blob/master/src/om_a_1/core.cljs
@adammiller: will look into it later, thx
Can anybody help me? I am playing with the om next tutorial and trying to add a modal dialog component but for some reason the first transaction doesn’t trigger a rerender but all transactions after that do. And I have no idea why. The code is here: https://gist.github.com/griff/e2bd4b41bc9f3fee66fe
@griff i haven’t pulled it down and tried it yet, but just glancing at the code I’d suggest adding the keys you want re-read at the end of your transact call: https://github.com/omcljs/om/wiki/Documentation-(om.next)#transact
@griff: what do you mean by the first transaction?
I'm getting what I think is the expected behavior
(after deleting an unexpected (get test)
in the query of the Person
component)
The first time i press a button after reload nothing happens (other than the console telling me that the transaction was made). Second time i press the button and whatever action I do after that it rerenders just fine.
@griff: not able to reproduce
anyway, if your problem happens with reloads, maybe you should write your code to actually be reloadable
e.g. defui ^:once
actually exists
also defonce
your reconciler should help
the latter definitely being the more important one
Hi guys, is there any function that we can evaluate props of a component based on its query ? To test in repl
Morning all! I must be missing something with how the reconciler is merging my remote data? It seems to me that if I have normalization activated, every remote call replaces any of the :by-id tables that are in my state instead of merging them...I'm guessing this is by design?
@griff: @anmonteiro is right, I had the same issue when playing with Om
@nxqd: One of my approaches has been to run the query through the parser and check results. i.e. (parser {:state app-state} (om/get-query RootView)). I can do this at REPL quickly
@nxqd: If you need to change a parameter for a component on screen you can use the (def root-view (om/class->any reconciler RootView)) (om/set-query! root-view {:params {:id 10}})
@nxqd: parser's read methods would be helpful
@nxqd: is that all?
I'd say some things are not quite right in your approach
you eventually have to return some data in your client's reads..
your app state also looks kinda spotty
I'm not sure why you have :dom-com/props
in your state, this is supposed to be a bogus key only used for routing. notice that the parser recurses on this key
in short: your :project-page
client read method needs to actually grab something from the local state whenever the remote data has been merged
hmm I think I misunderstand something here. So the {:value
in read function does take the data from remote when they are returned as well ? Is it only used for local data ( cache ) only ?
@nxqd: nothing in the parser is automatic
remote
instructs Om to grab remote data, that data is merged into your app state whenever you call the callback in your implementation of send
when your parser runs in local mode, and the remote data you just fetched is there, you need to go get it
example: https://github.com/swannodette/om-next-demo/blob/master/todomvc/src/cljs/todomvc/parser.cljs#L25-L30
so after being instructed to get data from remote. When it gets data from remote it will re run the read again ?
@anmonteiro:
again, you are correct, now I have the same question why I have data in :com-dom/props
? I should have data in :project/page
instead right ?
@nxqd: right
I might have the same question as @ztalky ask in the morning. I can see that we have the recursive call in read :dom-com/props
. But the thing is even if I return {:remote true}
in subquery, it doesn't hit the server. The query only hits the server when I return {:remote true}
in root query.
@nxqd: right but that is something we already discussed
in summary: since you are using recursive parsing, the parser at the top needs to know if the parsers that it calls need to go remote
in your case, you can simply replace {:value (parser env query target)}
with (parser env query target
and remove the remote
too
let the underlying parser decide what to do
these two functions come to mind as an example of what's being discussed here: https://github.com/awkay/om-tutorial/blob/master/src/main/om_tutorial/parsing.cljs#L191-L228
In the context of Om.next - what are "colocated queries"? in the second tutorial it introduces this term, but I'm not quite sure what it means
mentioned here - https://github.com/omcljs/om/wiki/Components%2C-Identity-%26-Normalization#identity
@mrjaba: Colocated means that queries are defined along-side / as part of the component logic / definition
@geraldodev thanks, but I don’t think that is my problem (I’m not using get-in
)
I think my issues are all related to components being created in code paths that are outside of an om controlled render.
@dnolen: regarding our conversation earlier today (about tempids), it looks like it does work as expected, so I must have been doing something wrong yesterday
@anmonteiro: ok, phew
and there are tests in place for :id-key
@anmonteiro: still something I’ve been thinking about - how to catch typical broken invariants and emit meaningful errors/warnings when things go wrong
test-tempid-migration
uses an id key
@dnolen: I like your line of thinking there
we add an invariant
React's mechanism would probably work well
I know they use it a lot
yep. does cljs's compiler elide those?
when you use elide-asserts
great
so no additional logic to be implemented, just really use normal assertions
yes definitely a good first step - maybe later consider a custom warn
macro or something that doesn’t hard error
@dnolen: can also make a simple macro that uses goog.log
, people will have it on in development
that wouldn't hard error
btw, PR#575 is just scratching the itch that I've had since I've seen query->ast
and then ast->query
for each function call. It's a minor thing but using query-template
& replace
seems like a great fit there
Maybe I'll have some time on the weekend to work on that. I'll file an issue just for reminders
hah! didn't think about that
I agree, thus submitting it
@dnolen: btw: when I run the tests at the node.js repl, I have to restart it to make it see the new code updates
and (require 'om.next.tests :reload)
or :reload-all
doesn't seem to do anything
@anmonteiro: hrm the later bit seems weird to me
I usually just use the load-file
special fn via my IDE/text-editor key bindings to re-eval the contents
ah..!
well, typing (in-ns 'bogus)
and then requiring the tests again still sounds better than restarting the whole repl
let me confirm that it works
@dnolen: nope, still doesn't work
it does work in the figwheel repl, though, without switching namespaces
not sure if a bug in the node repl, or if it's a result of figwheel hotloading
@anmonteiro: that’s just figwheel hotloading
I have a question about semantics; this probably isn’t the perfect place for it but happy to take pointers elsewhere. If Om is characterized as “Graph Query View”, what does the Graph part mean exactly? Similarly for GraphQL. How are the links between objects, or the system’s treatment of them, different in quality from relations in a relational db (or are they not — since the graph is a higher level idea and you can represent a graph in a relational db)
@anmonteiro: hrm weird yeah I see that - probably some kind of cljs.test bug
@jeremyraines: except representing graphs in a traditional SQL store is a complete pain
@dnolen: thanks
gonna start running tests in figwheel
@dnolen: I could probably get your om-next-demo updated with instructions on how to run it, and running, for people to clone it and get it running in their machines
if that's something you'd like
@anmonteiro: if you feel up for that, feel free to take that on - but don’t feel obliged
It's something that people are always asking how to run
but it doesn't seem complete
e.g. UI doesn't update when you delete a todo
looks like a good example of an app with clojure backend & datomic; I'd say it would be good to get it up and running both as a showcase and as an example for people to tinker with
by the looks of it, I'd say there are things that you didn't have time to implement?
@dnolen: if there are any other things that you remember are missing please say so, for me to note it down
also forgot to open the invariant issue, going to do that now
@anmonteiro: that’s not really one issue
for that I will happily just takes PRs as people encounter good places to introduce assertions
right, but the macro thing is there too
and I had literally just clicked the 'Add' button when I read what you just said 😇
edited
Sorry, busy so my avail is spotty. I'll be around in 30 mins or so, or possibly in the morning
Have anybody else experienced that Safari is extremely slow or crashes when using Om Next?
When I run https://github.com/omcljs/om/wiki/Queries-With-Unions the first button press is VERY slow.
Is params of IQueryParams considered to be pure or is it ok to have a param like the current location path for routing?
@dnolen: OK thanks. But is it just older Safari’s? Because I am pretty sure that I am on the latest.
@akiel: I don’t know what you mean, if you mean sticking an atom in there, no not generally a good idea
if you mean whether the query should be allowed to change over time - yes that’s the idea
@dnolen: I mean the latter - changing the query over time - but without using set-query!
but than if this is the idea - I miss a clear way to force a re-render of a component with such query params
using set-query! changing the params to a value which would be the same as when params would just be re-evaluated seems strange
ok this one: https://github.com/omcljs/om/issues/485