Fork me on GitHub
#om
<
2015-11-22
>
dnolen00:11:18

a slow paced walk through of the autocompleter

dnolen00:11:38

should answer a lot of different questions people been asking in one big swoop

mfikes06:11:49

David Nolen’s auto-completion widget ^^^ ported to React Native: https://github.com/mfikes/auto-completion (demo included)

steveb8n08:11:11

@mfikes brilliant work. A real confidence builder to see it implemented so quickly

grav11:11:55

@dnolen: re: the auto-completion example - seems a (def send-chan (chan)) is needed before the definition of reconciler.

dnolen12:11:57

@grav: fixed, thanks

mfikes12:11:09

@grav: Yes, that's what I found when putting together the React Native port. David probably didn't intend for that to be an “exercise for the reader”.

sebn13:11:21

hello everybody

sebn13:11:56

noob question here: I was reading the "Components, Identity & Normalization" section on the om.next wiki

sebn13:11:11

and I'm a bit confused regarding normalization

sebn13:11:47

isn't it a bit strange to have the RootView depend on the Person component

sebn13:11:08

just to "reuse" the query?

sebn13:11:24

please note I may be totally misunderstanding this part simple_smile

sebn13:11:01

I would have naturally expected some kind of separated query to be reused in both the RootView and the Person component

sebn13:11:14

so the RootView doesn't have to depend on it

dnolen13:11:21

for what benefit?

dnolen13:11:35

real UIs largely have this static up-front relationship

dnolen13:11:54

reusable components are separate topic

dnolen13:11:57

they don’t need queries anyway

sebn13:11:37

hmm ok, I not such experienced with react either, so I may be missing a lot of things

dnolen13:11:58

if you think UI builders like Interface Builder or markup isn’t a bad idea

dnolen13:11:16

then you shouldn’t have a problem that queries are built up this way simple_smile

dnolen13:11:28

all of these things are static hard coded things

dnolen13:11:12

that said queries need dynamism and there’s support for that too

sebn13:11:56

I was wondering, assuming I may have multiple child components both having the same "identity", which one's query I should "reuse" from a parent component

sebn13:11:31

but well, I think I'll need to read more, look at more code, and get back to what you said later

sebn13:11:27

there have been too many interesting things to look at recently: react, cljs, om(.next), reagent, re-frame, FRP, declarative queries...

sebn14:11:23

I started to play with all of them

sebn14:11:55

I found reagent easy to get started with, but quickly feeled like all my components where depending on one or more "globals" (atoms)

sebn14:11:41

then looked at om.next (I didn't really get Om first time I looked at it, probably because I was a clojure noob, not yet comfortable with protocols / reify)

sebn14:11:09

was hooked by the way reads/mutations were separated

sebn14:11:39

and the way multimethods were used

dnolen14:11:11

multimethods aren’t required, just done that way because it’s easy and an OK fit

dnolen14:11:33

as far as your first question, identity and queries are really separate concerns

dnolen14:11:01

without more information, I don’t understand why you would pick one query

dnolen14:11:06

you would need them all

sebn14:11:28

I'm probably confused because I'm trying to apply "FRP-likeish" design

sebn14:11:56

trying to have a "stem" state, and derived "properties" (I think it's the right word?)

sebn14:11:48

well sorry for the vague question

dnolen14:11:07

right I would not try to apply anything you’ve learned elsewhere to Om Next

sebn14:11:08

will play more, and come back with a more concrete one

dnolen14:11:11

it will only cause problems

sebn14:11:18

seems so simple_smile

dnolen14:11:29

Om Next stands on it’s own, there really nothing like it even with all the ideas borrowed from elsewhere

sebn14:11:33

better start by following the arrows

sebn14:11:38

actually, I was trying to have multiple "pages" components, and switch between them according to some state, I was not sure what was the best way to do this, maybe a multimethod, but abstracting the RootView children to later make it depend on some child component (Person) was feeling strange

sebn14:11:56

would be nice to have some example of "pages" components switching

sebn14:11:06

@dnolen: do you have any pointer?

sebn14:11:04

will try to clarify: let's say I want to implement an address book app, first displaying a contact list, and when I click on some contact, replacing the main content (except top nav) with the contact detail

sebn14:11:10

how would one achieve this? multimethods? if/else? another way?

sebn14:11:19

(please not I'm not asking for the complete solution, but some keywords/pointers may help)

dnolen14:11:18

@sebn I would let other people describe how they are solving this problem

dnolen14:11:38

I don’t have any specific pointers, suffice to say there are a lot of ways to do it

sebn15:11:43

@rburns: thank you very much

juhoteperi15:11:03

Is there yet any example how to do remote mutations?

dnolen15:11:46

@juhoteperi: probably, the om-next-demo on GitHub shows this too

juhoteperi16:11:13

Oh right, I didn't notice the default mutate with {:remote true}

paulb17:11:10

I have a subcomponent event that uses transact! in a function provided by Root. By itself everything works correctly and the app re-renders.

paulb17:11:18

However I also want this event to update the subcomponent's local state. But when I add update-state! only the subcomponent re-renders. How can I get everything to re-render?

dnolen17:11:00

@paulb it’s unclear what you want to achieve

dnolen17:11:14

everything you’ve described so far is how it’s supposed to work

paulb17:11:10

This is for a timer component with :seconds-left in local state. When it reaches 0, it transacts which affects components above it. But it also resets its own local state :seconds-left

paulb17:11:20

the problem is I cannot both transact and update local state, or transact does not re-render the way I want it to

dnolen17:11:23

this is just too much context

dnolen17:11:35

outside of what you are attempting there’s either an identifiable bug or there isn't

dnolen17:11:49

if you believe there is than demonstrate the issue isolated from whatever you are trying to do

paulb17:11:04

ok, I just wanted to make sure I'm not missing something

dnolen17:11:14

so far I can’t say yes or no

dnolen17:11:17

not enough information

juhoteperi18:11:51

When I have a component with a identity (`[:links/by-id _id]`) is it possible for the component to access other data besides the link's properties? In this case I need the current users role.

dnolen18:11:38

not sure what you mean

dnolen18:11:51

if that information is in the linked to thing then nothing more to do

bplatz18:11:52

@juhoteperi: If what you are trying to do is access :user/name in multiple components then its likely that making your parser recursive is an option. Another option is to use om/shared to store something like this, although I think it should be used with caution as it gets away from part of the point of this all.

bplatz18:11:34

Here is a simple read method that is getting the parser via destructuring the env, and then calling it again for other elements of the query.

bplatz18:11:39

(defmethod read :ui/quickview
  [env key params]
  (let [{:keys [state parser query]} env
        keywords (filterv keyword? query)
        joins (filterv map? query)
        joins-value (parser env joins)
        keywords-value (pull-ui state keywords)]
    {:value (merge (first keywords-value) joins-value )}))

bplatz18:11:51

So a simple, perhaps naive solution to your problem would be to have a read method set up of :user/name, and when you see it in the query of other components, call the parser again with [:user/name], then merge it back into your results.

bplatz18:11:28

Has anyone tried out path optimization yet with datascript? I need to tackle it today/tomorrow, and my first order is to figure out if Ident is required, and then if so, how to use it with datascript.

juhoteperi18:11:44

@bplatz: Thanks, I now understand that I need to handle this in parser myself

tony.kay19:11:07

@bplatz: have not tried it out yet with anything. An ident is required on the component. See default-ui->props

tony.kay19:11:36

have to have an ident and a query

tony.kay19:11:06

then it will try running that sub-query through the parser directly

tony.kay19:11:18

if you return nil, then it goes back to doing a root query

dnolen19:11:02

so after doing the remote tutorial it’s clearer exactly where we need error handling

dnolen19:11:18

feedback on this issue thread welcome

dnolen19:11:38

will try to get this tackled this week along with touch! and the mutation results issue.

paulb19:11:12

@dnolen This is an isolated example of what I was talking about. sorry it's long, important part is at line 30 https://gist.github.com/prbroadfoot/b8801772d2a41409ef86 There is probably a mistake in my reasoning about how re-rendering works, I am still pretty new at React

bplatz19:11:31

It appears I am no longer able to invoke a transaction using the reconciler as the first argument: Assert failed: transact! invoked by component that does not implement IQuery

bplatz19:11:12

I used this in my router, as I had goog.events to listen to goog.history for route changes, and invoke a transaction 'out of band' of the app itself.

bplatz19:11:47

Is that intended behavior? I suppose I could set up the route listener inside my root component if so... but want to make sure.

bplatz19:11:13

This is how I call transact!: (om/transact! reconciler `[(r/route-change {:route-map ~route-map}) :r/router :r/route])

bplatz19:11:27

Sorry.... my error.

bplatz19:11:13

FWIW, the routes hadn't loaded yet and I had no reconciler object present.... need to be careful that loading of stuff is in proper order.

dnolen19:11:23

@paulb: will have to take a look tomorrow if somebody doesn't get to it first. Thanks for smaller example.

dnolen19:11:49

@bplatz: sounds like we're missing a precondition

paulb19:11:19

ok, thanks simple_smile

anmonteiro20:11:34

@paulb line 57: {:reset-message-fn #(om/transact! this '[(reset-message) :message])}

anmonteiro20:11:42

you need to re-read what was mutated

anmonteiro20:11:48

in this case, :message

tony.kay21:11:17

@dnolen: The new recursive AST stuff seems to break process-roots. I’m trying to track down the problem.

tony.kay21:11:34

Ooops. ok. It was the query-root rename. However, process-roots does seem to be broken when there is no root again. I’ll produce sample cases in your bugs devcard.