Fork me on GitHub
#om
<
2015-11-24
>
adamfrey00:11:44

I took a working copy of the Remote auto-correct tutorial and added a new root parent component to the AutoCompleter component, modeled after @jdubie’s om-next-router-example. That stopped the remote :send function from being called like it was before. I delineated the small amount of code I added at the bottom of this Gist: https://gist.github.com/AdamFrey/201aedc47ee0014c7646

adamfrey00:11:33

I’d be very thankful if someone could take a look and see if I’m doing something wrong.

adamfrey01:11:23

The only thing it does is add a union query at the top level. I get no errors, everything renders correctly, but :send is never called.

noonian01:11:56

@adamfrey: I think it’s because in your :page read method you are not calling the parser in remote mode so you are never returning a remote query

noonian01:11:32

so something like that might be closer to what you need to do

adamfrey01:11:00

ok, I didn’t know about “remote” mode, so I think that’s part of my problem. The remote hook still isn’t called when I substituted your code, but I’ll keep trying things

noonian01:11:30

you should be able to test this by just calling the parser directly

noonian01:11:17

the parser either returns data returned from :value in your read fn or a query to execute on the remote server when run in remote mode, so you need to get it so the remote mode when run on your root components query returns your remote query.

noonian01:11:45

so if you called the parser with [(:search/results …)] you should see the remote query, and calling it with :pages doesnt return it which is the bug

adamfrey01:11:24

ok, thanks!

wilkerlucio02:11:15

hello, there is someone willing to help am om adventure buddy, I would like to someone else to test this snippet (no dependencies, if you have a devcards+om.next project setup it will do) and see if it's working, this is a devcards of the example on the om.next quickstart page, and I can't get it to work here https://clojurians.slack.com/files/wilkerlucio/F0F54JPQT/-.clj

wilkerlucio02:11:33

here when I click on the button, the parser state updates correctly, but the ui don't

taylor.sando02:11:53

You need to add query params to transact so om knows what you want updated, i.e. (om/transact! this '[(increment) :count])

Oliver George03:11:23

I'm building an om.next query from subcomponents which have overlapping data needs. Is there a way to dedup the query (kind of deep merge I guess) so that the duplication is removed?

Oliver George03:11:27

Something like...

Oliver George03:11:27

(= (query-scrubber [:A {:B [:C]} {:B [:D]}] [:A {:B [:C :D]}])

wilkerlucio03:11:31

@taylor.sando: tried that, still no updates =/

wilkerlucio03:11:55

@olivergeorge: I believe you can do dedup using Transit at the data transfer level

Oliver George04:11:08

@wilkerlucio - thanks, not sure I understand how that might work. I've got a little helper script which transforms everything into maps and does a deep merge.

thomasdeutsch08:11:38

@dnolen: for the initial read, :query-root will be :om.next/root even if all my components have a om/Ident and :pathopt true is set. After a mutation, the reader function will get called with the query-root set to the ident.

artemyarulin09:11:55

@tony.kay Bit thanks for https://github.com/awkay/om-tutorial The idea of using devcards + figwheel for the tutorial is just amazing, super cool!

dnolen12:11:42

@thomasdeutsch: of course since nothing has an ident the first time due to pre-normalization. You'd have to fix the initial data to make that work.

dnolen12:11:24

@thomasdeutsch: probably just a bug

dnolen12:11:08

@olivergeorge: there is not. Lift the query if you must. But I would perfectly fine with duplication

dnolen12:11:39

@adamfrey: using a union query at the very root of the application is not supported. Will probably throw if you try that from now on.

thomasdeutsch12:11:23

@dnolen: so, basically, :query-root can not be used in my initial read - and the :db-path strategy from @tony.kay is still the only solution, since i am unable to set :query-root manually.

dnolen12:11:20

@thomasdeutsch: this requires some thought, currently you must start with a QueryRoot and you’re asking to start at IdentExpr

dnolen12:11:53

don’t really want to go there, just fix your data for now

dnolen12:11:12

aka {:app/root [:some/ident 0]}

thomasdeutsch13:11:47

@dnolen: No, it is not about the place i am starting from - it is the missing option to tell the parser on what entity to parse on, when i use a recursive reader (a reader that is calling the parser on a sub-query)

dnolen13:11:15

@thomasdeutsch: I don’t know what you are trying to do, but it seems you are not understanding what I said

dnolen13:11:25

I don’t really care about the specific details of what you’re attempting

dnolen13:11:43

I’m just answering what you should do if you want to basically start with idents

dnolen13:11:54

the answer is you can’t, but you can simulate it at the next step

dnolen13:11:02

by hard coding the ident into your initial data

adamfrey13:11:57

@dnolen: good to know. I haven’t seen any other ways of doing top level “routing” from community examples, so I’ll have to do some more reading and experimenting. @jdubie, David’s message about Union Queries is relevant to your om-next-router-example

dnolen13:11:11

@adamfrey you can no longer do that in master, it’s a hard error

adamfrey13:11:19

thanks! That’s helpful

dnolen13:11:50

@adamfrey: as much as community help is appreciated I just don’t have time to read through all these other examples that people are generating for lack of time

dnolen13:11:04

if it’s not demonstrated in an example I wrote do not take it as anything definitive

dnolen13:11:12

ask me first if you are uncertain

adamfrey13:11:21

got it. Thanks for your help

dnolen13:11:26

@wilkerlucio: ah k this is devcards only issue

dnolen13:11:51

@bhauman: needs to provide state hooks for stuff like this to work, I haven’t followed up with him about this

exupero14:11:05

I have tests that exercise my app and change the app state, but assertions immediately after mutations fail because they happen before the next render is flushed. They pass if the test sleeps ~16ms after mutations. Is this the right way to handle waiting for renders, or is there a better strategy?

dnolen14:11:13

@exupero: testing on the async rendering loop is not something you should do IMO

dnolen14:11:14

if you must you can supply *raf* override, but I don’t recommend that either

dnolen14:11:38

the big idea in Om is all this stuff is a huge waste of time

dnolen14:11:47

parse returns the UI data tree, just test that

dnolen14:11:59

for visual stuff just use devcards

exupero14:11:47

Thanks. I’ll explore that direction.

wilkerlucio14:11:36

@dnolen: I also tried on one external page and it didn't worked there too, but this one needs more confirmation from my part, I'll try a new setup and hit you if it still an issue

dnolen14:11:02

@wilkerlucio: I doubt that but I’ll double check

dnolen14:11:10

it’s not possible to make your thing work in devcards

wilkerlucio14:11:14

what's in there that's not possible to work on devcards?

wilkerlucio14:11:58

since I have other more complicated things working on devcards, I don't understand why this one doesn't

dnolen14:11:32

because devcards just doesn’t support Om Next period

dnolen14:11:40

it has too many assumption about state management

dnolen14:11:05

and the hook that was there that would support Om Next wasn’t actually working

dnolen14:11:24

anyways @bhauman understands the problems and bugs

wilkerlucio14:11:16

so, you are saying that currently om.next doesn't work at all on devcards? nothing would update?

dnolen14:11:34

no the problem is very subtle

dnolen14:11:13

it can obviously work since that’s how I test

dnolen14:11:03

@wilkerlucio: I just confirmed your example works fine on a normal page as I said

wilkerlucio14:11:19

ok, thank you

dnolen14:11:56

the problem is entirely around if the root component needs to re-render

dnolen14:11:26

Om Next controls it

dnolen14:11:48

but since it didn’t mount it … problems

dnolen14:11:57

unlike om/add-root!

dnolen15:11:05

getting to the point where I’m more than happy to take PRs - I wrote up some quick notes on the contribution process

denik16:11:16

Why do components not rerender on local state changes?

denik16:11:23

(defui Counter
       Object
       (componentWillMount
         [this]
         (om/set-state! this {:count 0}))
       (render
         [this]
         (let [count (om/get-state this :count)]
           (dom/button
             #js {:on-click #(om/update-state! this update :count inc)}
             (str count " +1")))))

(def counter (om/factory Counter))

anmonteiro16:11:55

you have a mistake there

anmonteiro16:11:10

in React it's onClick and not on-click

anmonteiro16:11:38

the wiki documentation for Om Next doesn't have docs for update-state!

denik16:11:51

thanks @anmonteiro but it still does not work

anmonteiro16:11:00

it does work for me

denik16:11:35

ah now it works, okay thanks again!

dnolen16:11:28

@anmonteiro: feel free to add!

anmonteiro16:11:40

just checking

anmonteiro16:11:12

also no docs for get-ident

anmonteiro16:11:14

adding that one too

denik16:11:33

shouldn't this increment infinitely using requestAnimationFrame?

(defui Counter
       Object
       (componentWillMount
         [this]
         (om/set-state! this {:count 0}))
       (componentDidMount
         [this]
         (om/update-state! this update :count inc))
       (componentDidUpdate
         [this _ _]
         (om/update-state! this update :count inc))
       (render
         [this]
         (let [count (om/get-state this :count)]
           (dom/div nil
             (str "COUNT: " count)))))

(def counter (om/factory Counter))

denik16:11:11

It stops at 4 in my case

denik17:11:55

it also throws when no props are passed in

Tim18:11:21

state works similarly to atoms, don’t they?

dnolen18:11:44

@tmtwd: what do you mean?

Tim18:11:33

the way you update atoms vs the way you update state

Tim18:11:03

but I think I got it now so it doesn’t matter too much

tony.kay18:11:42

@dnolen: FYI: Added path optimization to a demo app...works fine for me so far.

dnolen18:11:40

@tony.kay: cool! thanks for the feedback

caleb19:11:06

Is this the intended AST representation of a union? (The key in the child is "[:type1 [:field]]")

caleb19:11:40

(Hi by the way!)

dnolen19:11:22

@caleb: no that’s a bug, file an issue

bannerintheuk19:11:03

Hi folks....Completely new to clojurescript and Om. Could anyone offer a bit of advice on how to properly use/intergrate the cljs fabricJs library with Om.

caleb19:11:09

@dnolen: Okay, thanks

bannerintheuk20:11:00

Much appreciated..thank you

kevinmershon22:11:01

This feels like a really stupid question, but is anyone successfully using reference cursors in om (now, not next)? I've got a fresh install from lein-figwheel copy-pasting the sample code from https://github.com/omcljs/om/wiki/Advanced-Tutorial#reference-cursors and I'm getting Uncaught Error: No protocol method IRenderQueue.-queue-render! defined for type cljs.core/Atom: [object Object]

dnolen22:11:03

@kevinmershon: make sure you are not trying to use any of the alphas

kevinmershon22:11:53

Pretty sure I'm on 0.9.0 but I'll double check when I'm back to my computer.

dnolen23:11:07

@kevinmershon: yeah I would double check, if that doesn’t work I would also try the release prior

dnolen23:11:23

I won’t have time to bring Om Now update to date until Om Next goes beta at least

kevinmershon23:11:52

@dnolen: Definitely worth a shot. I have no idea how you have time to do a third of what you're doing. The fact you still take time to make yourself available to the community on top of your development time and talks is just astounding.

kevinmershon23:11:43

Getting the same rolling back to 0.8.2. Looks like I'm using channels!