Fork me on GitHub
#om
<
2015-11-19
>
Oliver George00:11:58

Can anyone confirm if om 1.0.0-alpha22 is technically "stable" for the purposes of running om.now with React 0.14

Oliver George00:11:46

I'd like to try https://github.com/JedWatson/react-select but it requires react 0.14 and om 0.9 release depends on 0.13

dnolen02:11:31

@olivergeorge: pretty sure the alphas aren’t good for om.now

dnolen02:11:40

that probably won’t get settled until we get closer to beta

jamesnvc02:11:54

hello; I've been using om for a while & am trying to figure out om.next

jamesnvc02:11:53

I am kind of confused as to how :remote mutates work; I wrote a simple example based on @dnolen 's TodoMVC, but when I try to add an element the change isn't reflected on the client

jamesnvc02:11:40

i.e. I do (om/transact! s [(foo/create {:foo/name "new-name"})] which goes to the remote fine, and if I update I see the new foo

jamesnvc02:11:50

but it isn't reflected in the client until I refresh

jamesnvc03:11:15

The remote is is giving {:value [:foo/list]} but that doesn't make it reload that? I also heard mention of using temp-ids with automatic reconcilliation in the clojure conj talk, as that what I should be using here? optimistic update on the client with temp-id?

bplatz03:11:39

@jamesnvc: {:value ...} has no impact on re-render, it is only a suggestion. In a transaction, you'd append the key... so change your transact call to: [(foo/create {:foo/name "new-name"}) :foo/list]

bplatz03:11:19

If you want to see what components would be re-rendered based on :foo/list, do: (om.next/ref->components reconciler :foo/list) in your repl.

colinf09:11:57

Thanks @tony.kay - that remotes simulation example is really useful

wilkerlucio11:11:07

morning people, does anyone have an example repository with Om.next + Devcards + Reconciler?

martinklepsch11:11:18

@wilkerlucio: I think @jannis has some devcards + om.next stuff

wilkerlucio11:11:35

I see this code uses a function om/mock-root, interesting simple_smile

wilkerlucio11:11:33

thanks @martinklepsch, I was looking at @jannis code before, but like he said he wasn't using reconciler there

jamesnvc11:11:15

Thanks @bplatz, I'll give that a try

jamesnvc14:11:03

So I heard mention of this :tempid map in @dnolen 's Clojure Conj talk & I see where it gets called in om/next.cljs, but how do you actually use it? Do you make the action thunk return {:tempids {1 2}}?

tony.kay15:11:28

@jamesnvc: close. map from refs to refs

tony.kay15:11:28

Generate tempids w/ (om/tempid). Then return {:tempids { [:thing/by-id tempid] {;thing/by-id real-id] } }

tony.kay15:11:12

note: there is a bit more expansion coming in Om here related to action

wilkerlucio18:11:55

hello; how are you handling temporary input values on om.next? are you using it as some local state or putting it on a root pointer like :something/new?

dnolen19:11:55

@wilkerlucio: either way could work, it really depends on whether you want to time travel on that state

dnolen19:11:07

I might put edit state in app state

dnolen19:11:15

but not transient input field value in app state

wilkerlucio19:11:25

thanks @dnolen, I'm gonna try using edit state in app state

jonsmock20:11:51

How often should we be updating the Documentation page for om.next? I see set-params! still on there

jonsmock20:11:23

I know set-query! has sort of absorbed this functionality

jonsmock20:11:53

I can update too, if ya'll want - I've been in lurking mode, because I don't know how things work yet

dnolen20:11:18

@jonsmock: it’s better to ask first as you have simple_smile

dnolen20:11:24

feel free to fix in this case

jonsmock20:11:34

Removed the set-params! and updated set-query!

jamesnvc21:11:46

So I continue to be confused how :tempids work

jamesnvc21:11:28

My action returns something like {:tempids {[:foo/by-id tmp-id] [:foo/by-id new-id]} but I don't seem to see that reflected in the client

dnolen21:11:49

@jamesnvc: could be a bug, but i would isolate your problem

dnolen21:11:01

you can test the :tempids in 20 lines of code

dnolen21:11:10

the tests in om.next itself are trivial

jamesnvc21:11:14

should I expect to see the id updated in the client though? I'm not even sure what I'm doing makes sense

jamesnvc21:11:27

like, it should automatically re-render components that have that old id?

dnolen21:11:05

as long as you said you wanted to in your transaction

dnolen21:11:11

there might be a bug though

dnolen21:11:22

but again I would only look at something minimal and complete that demonstrates the issue

jamesnvc21:11:37

okay, I will try to isolate, thanks!

balduncle21:11:06

I have no prior Om, React or ClojureScript experience and am going through the Om Next tutorial. Curiosity question... is there a way to call transact! in a for loop but still have the components re-render before the loop is complete? (for [x (range 1000)] (om/transact! reconciler '[(increment)])) This logs the transactions to the console but my Counter component doesn’t re-render until the loop is complete.

jamesnvc21:11:19

@balduncle: I don't think so, by design; React only re-renders on requestAnimationFrame, precisely so it doesn't have to repeatedly re-render 1000 times

balduncle21:11:44

jamesnvc: Okay, thanks. I’ll see if I can find some React doc about this.

dnolen21:11:57

@jamesnvc: rAF is not a React thing

dnolen21:11:00

it’s a Om thing

dnolen21:11:20

@balduncle: and no you don’t want do that (clarified)

jamesnvc21:11:22

I only know React in the context of Om, so I'm not sure what is what 😛

dnolen21:11:38

it’s precisely the kind of thing that Om discourages

dnolen21:11:47

you can override the behavior but it’s not recommended at all

rads21:11:13

should it be possible to call update-state! from a componentWillUpdate? I'm getting a No queries exist for component path error when I try to do so

wilkerlucio21:11:31

I've found that when I have a component that receives modified props that are partially from Om.next + extra data, then I update the component state, all props are lost in the next render cycle, is that normal?

dnolen21:11:51

@wilkerlucio: that’s another anti-pattern

dnolen21:11:55

you can’t do that anymore in Om Next

dnolen21:11:10

see om/computed

balduncle21:11:15

If you had a constant stream of data coming in that needed to be transacted I assume it wouldn’t lock up the UI if it was coming in super fast…?

rads21:11:17

I have a list that loads async from the server. I want to set a local :selected-item attribute when the list first loads for a default selection

dnolen21:11:21

if you need to add some side information

dnolen21:11:43

@balduncle: the whole point of rAF is who cares how fast the data is coming

dnolen21:11:57

you’re never going to see anything more than 60fps anyway

wilkerlucio21:11:15

@dnolen: nice, that's what I was looking for, thanks

balduncle21:11:17

dnolen: I won’t even see that though if my loop is stopping rendering from happening, right?

dnolen21:11:46

@balduncle: yes but that doesn’t have anything do with Om

dnolen21:11:49

that’s how JS works

dnolen21:11:05

if you have an expensive loop you block the browser from repainting period

balduncle21:11:25

Got it. Makes sense.

dnolen21:11:13

@rads just not enough information in your question

dnolen21:11:43

the server bits aren’t really relevant to the issue

dnolen21:11:56

you should be able to show a minimal example of what isn’t working for you

wilkerlucio21:11:33

@dnolen: using om/computed the computed properties are kept after a state update, but props are still being lost, this is intended?

rads21:11:57

@dnolen: ok, let me get an example going

dnolen21:11:02

@wilkerlucio: doesn’t sound plausible

dnolen21:11:14

@wilkerlucio: you’re just not allowed to modify props periods

dnolen21:11:21

all that stuff has to happen in parse

dnolen21:11:28

components never touch props

wilkerlucio21:11:43

@dnolen: I'm not trying to modify props, I'm updating the component state, I have a minimal case for the issue, let me paste for you

wilkerlucio21:11:13

on this component, when you click at the button the props go blank

dnolen21:11:22

@wilkerlucio: yeah so that won’t work simple_smile

dnolen21:11:32

you are breaking the contract between components

dnolen21:11:59

oh actually sorry

dnolen21:11:01

perhaps not

dnolen21:11:27

@wilkerlucio: and this is alpha22?

dnolen21:11:06

@wilkerlucio: yeah your parse won’t work

dnolen21:11:11

{:value …}

dnolen21:11:40

oh you’re not even supplying a parser

dnolen21:11:59

not recommended, make a proper parser

dnolen21:11:16

the read you supply can of course just be a simple function

wilkerlucio21:11:44

I don't understand the relation of the parser with the problem that I'm trying to point out

dnolen21:11:59

@wilkerlucio: nothing will work if you don’t supply a parser

wilkerlucio21:11:00

because the parser here is just supposed to be a mock to get something that works

jamesnvc21:11:05

Sorry to keep asking questions about the same thing here, but I see that my action returns {:tempids …}, but the return value of the thunk doesn't get sent to the client? It is very possible I am misunderstanding how this is supposed to work

dnolen21:11:19

@wilkerlucio: the problem is the parser is broken

wilkerlucio21:11:22

why when I update the child state it loses the props? I'm trying to understand this

dnolen21:11:41

@wilkerlucio: the components gets its props … from the parser

dnolen21:11:05

you’re just getting lucky the first render is all

dnolen21:11:36

@jamesnvc: the return the value of the thunk is never sent to the client that’s not how mutations work

dnolen21:11:39

the tutorials cover this

jamesnvc21:11:03

@dnolen: okay, that makes sense to me; I was confused how :tempids could possibly work in the way I was understanding

dnolen21:11:25

@jamesnvc: mutations return {:keys … :tempids …}

dnolen21:11:53

as the :value part, the actual mutation thunk is in the :action part

dnolen21:11:00

the result of most mutations are useless

dnolen21:11:03

db transactions etc.

jamesnvc21:11:25

oh, the :tempids is the in the :value? awesome

wilkerlucio21:11:43

@dnolen: thanks, working with a fixed parser

jamesnvc21:11:02

I guess I have to use something other than the datomic primary key as the id though? Since I need the result of the thunk to figure that out?

dnolen21:11:19

@wilkerlucio: the parser builds the UI

dnolen21:11:22

nothing works without

dnolen21:11:51

@jamesnvc: yes that needs to be fixed, legitimate bug

dnolen21:11:10

@jamesnvc: in the meantime I would thread an atom to collect this stuff

jamesnvc21:11:30

@dnolen: thank you very much, I think I understand what's going on now

tony.kay22:11:59

@dnolen: Hey David, I had an idea for merge-tree that might help things out quite a bit...let me know if you have a few to chat abt it

tony.kay22:11:56

or if you'd rather me just describe it in a issue

tony.kay22:11:48

I'll do the latter.

dnolen22:11:12

@tony.kay: I’m going to be side tracked for the next few days on a bigger problem

dnolen22:11:21

so everything else is on the backburner for a bit

tony.kay22:11:38

no biggie. I'm going to spend the next few days writing docs. I've written stuff down in issues

dnolen22:11:45

trying to see how hard it is model complex async coordination within send

dnolen22:11:00

i.e. typical hard stuff like autocompletion across the wire

dnolen22:11:21

I don’t see any challenges but want to make sure the API bits for manipulating queries is solid enough for this

tony.kay22:11:14

sweet. Look at the issue I just submitted (482)...it relates.

tony.kay22:11:39

(in that it is meant to make dealing with those queries and responses easier)

dnolen22:11:10

@tony.kay: after reading over it I don’t really understand it

dnolen22:11:18

might be easier with code

dnolen22:11:41

parsing the response doesn’t make much sense to me since you got back exactly that

tony.kay22:11:43

ok, will do. I'll work up an example that shows what I'm thinking...doing that for the docs anyhow

dnolen22:11:48

send is completely in your control also

dnolen22:11:04

so pretty conservative around anything that is solveable in send

tony.kay22:11:05

treat the response as the STATE...and what you sent as the query...

tony.kay22:11:20

but instead of running read, run a node merge

tony.kay22:11:30

at each ast of the sent query

dnolen22:11:51

still don’t get it

dnolen22:11:03

is this referring to the :query/root reconstruction stuff?

dnolen22:11:12

yeah then I don’t get it

tony.kay22:11:26

you want me to explain more, or just make code?

dnolen22:11:34

what I mean is I don’t get the point of it at all

dnolen22:11:53

probably because the issue doesn’t describe a problem

tony.kay22:11:02

We often need to write merge-tree, since the UI tree doesn't match the structure or the app state, right?

tony.kay22:11:41

e.g. the response from the server has to look like UI tree, but that isn't what is in our app state.

tony.kay22:11:53

you have auto-normalization for really simple case

tony.kay22:11:25

so, merge-tree is going to be a source of complexity in our code

tony.kay22:11:46

and we can leverage the parser to address this complexity (since we already have the query we sent, and the parser)

dnolen22:11:58

I don’t see how the parser can help you

dnolen22:11:03

parser makes a tree too

tony.kay22:11:15

if we do read, yes it does

tony.kay22:11:25

but really, it is just traversal

dnolen22:11:29

and that thing has the exact same problem

dnolen22:11:07

what you might be saying is ...

dnolen22:11:20

it’s easier to merge tree + tree and then normalize that to get the new db?

dnolen22:11:46

if you’re talking about extending the parser in some way

tony.kay22:11:48

sorry, I am assuming that you write you read-style functions to call parser recursively

dnolen22:11:00

then that will need a lot more rationale

tony.kay22:11:12

What I'm talking about requires no mods to parser

tony.kay22:11:24

I'll show you in code...give me a day or so

dnolen22:11:42

k sounds good

tony.kay22:11:08

it also doesn't require new code, really...but it gives nice help with the merge-tree problem

dnolen22:11:34

sure, yeah I just can’t understand anything from the issue itself at all

tony.kay22:11:43

the add would be (om/parser {:read read :mutate mutate :merge merge})...but not even that is required

tony.kay22:11:08

I'll stop distracting you and just write it simple_smile