Fork me on GitHub
#om
<
2016-04-15
>
settinghead04:04:06

is there a core.async-based implementation for om.next.server?

jimmy06:04:28

@marianoguerra: you can check the error from the send function. If you want to interact with the app, just assoc some error message to the next state, and it will be merged to the app.

jimmy06:04:10

@settinghead: core async based server ? what do you really want from it ? I'm curious

tomjack06:04:05

I was thinking about 'async read' when considering localforage, which has a callback API. I switched to directly using the synchronous localStorage API instead of thinking more about it

tomjack06:04:43

I think if we use our imaginations we can stop wanting 'async parsing'

urbanslug09:04:20

I have an opportunity to transfer one little part of a codebase to Om Next though it’s not using Om (using dommy) where should I start? Afraid it might conflict with Om now code being used elsewhere.

urbanslug09:04:22

Vague question I know

devth13:04:55

strange: this doesn’t actually work for me https://github.com/omcljs/om/wiki/Thinking-With-Links! - the linked item current-user is always nil

devth13:04:39

ok works after a (clean-builds) 😡

isak14:04:33

@urbanslug: what i did is to have some front end routes that need om.next, and some that need om now, and then added logic to mount and unmount om versions as needed

isak14:04:12

(in the function that handles browser route changes)

isak14:04:37

we haven't noticed any issues

urbanslug14:04:47

isak: another quick one did you encounter any issues with having both dependencies on the same project i.e did the different versions of react conflict?

isak14:04:40

i only have one version - alpha 32

isak14:04:04

because it hasn't changed om now, just om next

isak14:04:43

oh and for react i just excluded it, because we were already using it before using om at all

urbanslug14:04:07

@isak: Cool, thanks 😄

urbanslug14:04:23

Will come back with findings/feedback

symfrog15:04:44

I am trying to figure out how links (https://github.com/omcljs/om/wiki/Thinking-With-Links!) are intended to work. After reading the links page a few times, I expected the parser to invoke my read method at the root with the link key. This does not seem to be the case (my read method is not invoked with the link key). I am using a datascript db as my application state. As an example, if I specified the query of a component deep in the hierarchy as

'[:id :title [:current-user _]]
, I would expect the parser read method to be invoked similar to
(parser {:state conn} '[[:current-user _]])
, which is not the case.

symfrog15:04:01

Are links the right option to use when I need a portion of a component's query to be looked up at the root?

jannis15:04:41

Are there known issues with Om Next where components suddenly have an omcljs$reconciler that is nil?

kendall.buchanan15:04:42

@symfrog: I really struggled with that tutorial because of this: https://github.com/omcljs/om/issues/670

kendall.buchanan15:04:26

Having said that, however, after getting the dependencies right in the tutorial, I then couldn’t get Links to work in my own project (outside the basic, basic tutorial). Still stumped as to why.

kendall.buchanan15:04:56

alpha24 seems to be the release in which Links start working.

jannis15:04:34

I have this one component, where omcljs$reconciler, omcljs$parent etc. are nil about 50% of the time. It happens with no other components. It's really odd.

symfrog15:04:50

@kendall.buchanan: thanks, I am using alpha32 at the moment and seeing the behavior described after following the tutorial, does that issue mean that there is different documentation to use links somewhere that I am not finding?

isak15:04:07

@jannis we had an om gotcha the other day where if you do (om/get-query MyComponent), but then you tamper with the result, you lose (meta) information required by om

isak15:04:21

don't know enough about your program to tell if that is happening in your case

isak15:04:53

in our app it manifested as "no query found for path"

jannis15:04:35

I never mess with get-query results for that particular reason (breaking meta data). I think this may be a problem between Sablono and lazy children created with for.

jannis15:04:39

Yep, it seems like forcing children with doall or mapv solves the problem. There are good reasons why Om Next forces children by default. Sablono might not.

kendall.buchanan15:04:59

@symfrog: No idea. I’m also using alpha32, and can’t for the life of me get Links to work in my non-tutorial project. If I wasn’t so lazy (and there wasn’t a non-links workaround) I’d go back and do the tutorial over again in alpha32 rather than 24. But yeah, I’m not using datascript, so no insights from me there.

kendall.buchanan15:04:43

Ah, sorry, now understood your question: the issue I posted on om.next about documentation was simply pointing out the difference version dependencies between the two tutorials. So, no, I don’t know of any alternative documentation.

symfrog15:04:33

@kendall.buchanan: no problem, already helps to know I am not the only one struggling with it, thanks simple_smile

anmonteiro16:04:25

@kendall.buchanan: links are supposed to "just work" but you need to be using the default db format and db->tree

kendall.buchanan16:04:51

@anmonteiro: By default db, you simply mean passing a map of data as your state (as opposed to datascript)?

anmonteiro16:04:12

by default db I mean normalized data

kendall.buchanan16:04:37

Okay, I just refreshed my memory as to what about it didn’t seem right...

kendall.buchanan16:04:07

If I understand correctly, links should be available to subcomponents without being referenced in the root component...

kendall.buchanan16:04:23

Om was requiring that I provide a read function in spite of the ident syntax (e.g. [:user _]).

kendall.buchanan16:04:46

So I resorted to [:user], and provided a read function.

anmonteiro16:04:07

your queries might not be correctly composed

anmonteiro16:04:12

or structured

kendall.buchanan16:04:31

I don’t doubt I’ve done something wrong; it just hasn’t been obvious.

anmonteiro16:04:48

happy to have a look at the component query

kendall.buchanan16:04:32

Thanks, lemme see if I can provide something that doesn’t take up too much space...

anmonteiro16:04:32

so the query for Assessment is wrong

anmonteiro16:04:38

it’s not a link...

anmonteiro16:04:49

should be '[[:user _]]

kendall.buchanan16:04:45

K, I fat fingered that in my scissoring...

kendall.buchanan16:04:51

Updated it; still produces the same error.

kendall.buchanan16:04:03

Good catch, though.

kendall.buchanan16:04:22

core.cljs:9856 Uncaught Error: No method in multimethod 'course.component.reconciler/read' for dispatch value: :user

anmonteiro16:04:07

@kendall.buchanan: what does your parser look like

anmonteiro16:04:17

i.e. what multimethod keys does it have

kendall.buchanan16:04:48

Pretty standard, :read and :mutate.

kendall.buchanan16:04:40

Sorry, I hate to vomit my whole app into your lap. Thanks for looking at this.

anmonteiro16:04:00

@kendall.buchanan: I should have been more explicit

anmonteiro16:04:18

I meant what keys does the read dispatch on

kendall.buchanan16:04:28

Is there a chance there’s overlapping coupling?

anmonteiro16:04:32

well, the ones that are related to that path

kendall.buchanan16:04:13

Do you mean related to the :activities/current path?

kendall.buchanan16:04:37

To be clear, nothing in the app operates on the :user key, which is at the root of the state.

anmonteiro16:04:46

you’re most probably using recursive parsing

kendall.buchanan16:04:52

Yes, definitely.

anmonteiro16:04:09

where you should be using db->tree in the :activities/current multimethod

kendall.buchanan16:04:51

Perhaps the recursion isn’t adequate to support a link?

anmonteiro16:04:00

I’m not exactly sure why you would use recursive parsing in that case?

anmonteiro16:04:13

just returning :value (db->tree …) should work?

kendall.buchanan16:04:48

I’m really new, and this might stem from me hoping to use Om in a fundamentally flawed way...

kendall.buchanan16:04:18

What I showed you was a stripped down version of the component. In reality, I’m using queries to compute a variety of different fields.

kendall.buchanan16:04:59

That’s the more complete version… but you can see it’s conj’ing on from another multi-purpose query.

kendall.buchanan16:04:16

:answers/chosen and :questions/current, I also want computed.

kendall.buchanan16:04:25

Hence the recursion. Perhaps I’ve missed something simple?

kendall.buchanan16:04:20

@anmonteiro: I might simply need more experience with Om before the answer becomes clear, cause I might just be slaughtering the queries, for all I know.

anmonteiro16:04:28

the structure seems OK from a high level standpoint

anmonteiro16:04:50

but you might be able to get your result by just using db->tree

anmonteiro16:04:11

anyways, if you’re recursing the parser, maybe remove what has been computed by db->tree already

anmonteiro16:04:18

in this case, the :user link

kendall.buchanan17:04:54

Sweet! Removing recursion fixed the link.

kendall.buchanan17:04:09

Of course, I’ve broken my app, but that solved the mystery.

kendall.buchanan17:04:34

Thanks for entertaining that, @anmonteiro.

settinghead18:04:54

@nxqd: i checked the code for the server-side parser for om.next, and it seems that it assumes that mutation function that was passed into it is synchronous. in other words, i can’t have a mutation function that returns a core.async channel. in my mutation function, i’ll have to block my thread to get the results, and return it

thomasa18:04:12

Hi, I was wondering if someone can help me clear up a confusion I have with om-next. I'm having difficulty getting the app to only re-render components whose state has changed---instead it always re-renders everything on every state change! Unless I'm missing something fundamental, this isn't supposed to happen, right?

thomasa18:04:52

here's a super-minimal app that exhibits this behaviour:

isak18:04:49

@thomasa: your components don't have static om/Ident implmented, i think that is why

isak18:04:32

have to head out, hopefully that is the issue

thomasa18:04:46

ok that's interesting---I had thought om/Ident was only for normalisation; i'll give it a try

anmonteiro18:04:31

@thomasa: not sure I understand your problem, it seems to me that all those components are supposed to re-render

thomasa18:04:38

hmmm... I've added static om/Ident methods to each component and the app still works, but the same undesirable behaviour continues

thomasa18:04:13

@anmonteiro: surely only the first of the two BooleanBoxs should re-render? the contents of :b hasn't been changed.

anmonteiro18:04:53

I’ll try your example in a bit and get back to you

thomasa18:04:03

thanks, it's appreciated simple_smile

isak19:04:45

i remember reading earlier that when you transact, it will use the ident and query of the component you send in in order to determine what to re-read. but i don't see that in the api docs anymore

isak19:04:04

but wait

isak19:04:14

@thomasa: your transact is on the root

isak19:04:12

try to transact on your BooleanBox

thomasa19:04:44

@isak: I don't think I can---in this case the transact is fired by a button on the root component so it doesn't have the BooleanBox to hand

thomasa19:04:14

I'll give it a try with the transact coming from a different place, but I feel like it shouldn't matter where it comes from---the rendering process should only depend on the old state and the new state, surely?

thomasa19:04:57

ah I've been messing around with trying different things, and I've suddenly fixed the problem

thomasa19:04:19

It could be because I upgraded the dependency to the latest alpha

isak19:04:33

well i think determining what to re-render based on the query and ident of the invoking component was added as convenience, but you can also specify additional keys

isak19:04:21

hm, can you paste your new one?

isak19:04:19

btw i found the stuff i was talking about in the docs

thomasa19:04:38

urh, at the minute tbh I'm having difficulty recreating the behaviour

isak19:04:15

After the transaction, Om implicitly updates the initiating component based on its query.

isak19:04:33

i could see how it creates a problem for your app, but i'm not sure if that often comes up in real apps

thomasa19:04:08

Right, I see what you mean about using the originating component as a convenience; thanks for all your help. I've basically convinced myself now that the issue was entirely because I was using an old version alpha-22 rather than the latest... apologies to everyone---it was silly of me not to check that before asking here.

drcode20:04:16

Hi, is there any kind of information on how tempids are intended to be used yet? (documentation/blog post/etc)

anmonteiro20:04:01

also happy to clarify any real-world doubts you might have

drcode20:04:40

Thanks @anmonteiro- That makes it very clear for now. BTW, I'm still getting back to you as we discussed, just super busy atm...

isak21:04:35

for sending data to the server, what do people usually do? do you basically send back data that looks like what you'd get as a response from a query?

isak21:04:04

sending updated rows, i mean

fifigyuri21:04:45

hi, I’d like to generate an ul/li list for pagination. for the li I need to have keys, as I see in om-next there is a way to define keyfn but for a whole component. I started to decompose my paginator component, but it feels overcomplicated. Is there a way to define keys for the li generated inside of render?

anmonteiro21:04:50

@fifigyuri: (dom/li #js {:key 1})

fifigyuri21:04:36

@anmonteiro: I use sablono that simple scheme did not seems to work

fifigyuri21:04:21

ok, i should actually, thanks

anmonteiro21:04:47

@fifigyuri: so [:li {:key 1}] should work

anmonteiro21:04:51

or something like that

fifigyuri21:04:57

@anmonteiro: works, thank you. I noticed something I can not explain yet. I have this pagination component on the top and bottom of the page. Both are the same hanging on the same query. When I click on any of it (top or bottom) it updates, but the other one does not. But when I go to the other one and click prev or next it skips to the place where it should. So it seems like the other component is not re-rendered, only the one where the transact was issued.. Any ideas why that can be?

anmonteiro21:04:16

@fifigyuri: transact! will queue the component that called it for re-render

anmonteiro21:04:03

you need to specify keys to be re-read after the transaction call such that the components that hold those keys are correctly re-rendered

fifigyuri21:04:50

keys you mean key in a query..?

fifigyuri21:04:00

thanks, that explains that, but I’m wondering why the other pagination component is not queued too, although it’s outside the component of the transact!, but it’s declaring the same keys

anmonteiro21:04:59

@fifigyuri: by keys I mean the query keywords, yes

anmonteiro21:04:10

Om will queue the component instance

anmonteiro21:04:20

so the other instance that has the same keys won’t be queued

anmonteiro21:04:40

this makes sense because not every instance of a component needs to be re-rendered in most cases

fifigyuri21:04:51

ok, I understand, makes sense, when I want to change all components with a key, I need to explicitly declare it in the transact!

isak23:04:43

thats a good question. wouldn't be crazy to parameterize child joins for example