Fork me on GitHub
#om
<
2016-01-16
>
andrewboltachev00:01:35

Hi. Can anyone suggest, what this horrible error might be caused by? Using om-intermediate-template http://dpaste.com/209ZJK8

akiel12:01:04

@andrewboltachev: I was able to create a project with lein new om-intermediate-template … and after I had setup a datomic instance a lein figwheel runs without problems. Did you change anything in the project.clj?

akiel14:01:54

@pupeno: with om/computed

Pablo Fernandez14:01:31

(om/computed % {:onDelete delete-person}) ?

Pablo Fernandez14:01:07

And then, to trigger the event from the button, this is not working: (dom/button #js {:onClick #(js/console.log "foo")} "X")

Pablo Fernandez14:01:11

What am I missing?

akiel14:01:23

you have to get your delete function out of computed in Person and put it into the onClick handler

Pablo Fernandez14:01:45

akiel: yes, I know that bit, but the onClick handler the way I defined is not running.

Pablo Fernandez14:01:54

I’m not getting “foo” on the console when I press the button.

akiel14:01:57

the :onDelete they in the computed pros is only for you - it has no meaning regaring events

Pablo Fernandez14:01:21

I know, I know, I’m just trying to get the button to do something first.

Pablo Fernandez14:01:37

Mh… now it’s working.

Pablo Fernandez14:01:54

so, did the tutorial recommended onDelete because it’s a JavaScript property? why not on-delete? why even call the function deletePerson instead of delete-person? (yes, I’m asking at about the style)

akiel14:01:00

I would use clojure naming style when possible

akiel14:01:43

If you use sablono, you can even use clojure naming style for JS handlers

Pablo Fernandez14:01:30

Does sablono replace om.dom?

Pablo Fernandez14:01:05

I’ll probably be using it. Thanks simple_smile

akiel14:01:05

its like hiccup

Pablo Fernandez14:01:43

Do you know if it escapes values by default or is it an XSS waiting to happen (like, sadly, Hiccup)?

akiel14:01:19

no I don’t know

juhoteperi14:01:16

It is safe. It compiles Hiccup forms into React calls so only way to render arbitrary strings is through dangerouslySetInnerHTML

krchia17:01:35

but i get an error that i can’t google for when trying to execute config/samples/free-transactor-template.properties

krchia17:01:13

i get "-bash: memory-index-threshold=32m: command not found -bash: memory-index-max=256m: command not found -bash: object-cache-max=128m: command not found"

akiel17:01:37

this is a property file it’s not executable

akiel17:01:08

you have to execute bin/transactor transactor.properies after doing something to the template

krchia17:01:18

so how should i interpret "run the following inside the directory”?

akiel17:01:31

wait I don’t know the tutorial

akiel17:01:07

there you have it: bin/transactor config/samples/free-transactor-template.properties

akiel17:01:21

it says bin/transactor in front

krchia17:01:32

it’s two separate files

krchia17:01:51

i get another error if i only run bin/transactor

akiel17:01:53

it’s just running the transactor with some properties

krchia17:01:07

well, if im not supposed to do “. config/samples/free-transactor-template.properties” in terminal, i get "ConnectException Connection refused java.net.PlainSocketImpl.socketConnect (PlainSocketImpl.java:-2)” following the steps otherwise

akiel17:01:28

is the transactor running? what does it output?

krchia17:01:45

“Saving session... ...copying shared history... ...saving history...truncating history files... ...completed. [Process completed]"

krchia17:01:48

is this what you meant?

akiel17:01:08

no a typical output of the transactor looks like this:

akiel17:01:25

datomic-free-0.9.5130 $ bin/transactor config/samples/free-transactor-template.properties
Launching with Java options -server -Xms1g -Xmx1g -XX:+UseG1GC -XX:MaxGCPauseMillis=50
Starting datomic:, storing data in: data ...
System started datomic:, storing data in: data

akiel17:01:19

do you use linux or a mac and be in a shell?

krchia17:01:34

i use terminal in a mac

krchia17:01:43

not too savvy, otherwise i wouldn’t be following a tutorial

akiel18:01:54

so whats the problem with the transactor?

akiel18:01:17

I just unzipped the download and run the command from the tutorial

krchia18:01:22

i get this now: "Launching with Java options -server -Xms1g -Xmx1g -XX:+UseG1GC -XX:MaxGCPauseMillis=50 -bash: bin/classpath: No such file or directory Error: Could not find or load main class clojure.main"

krchia18:01:00

oh its working now

krchia18:01:42

thanks for the help simple_smile

akiel18:01:04

you started the transactor inside the bin dir?

akiel18:01:15

you have to do it from outside

krchia18:01:47

oh yeah i mean outside the bin directory sorry

caleb19:01:55

I have an Om Next project that has a form that has a variable number of line items that are editable. The problem is that when the number of lines is large (e.g. 200 lines), there is a noticeable delay when typing characters into a text box on the form. This isn't an Om problem, but a problem with how I designed these text boxes. On each onChange an om/transact! is run and the state is updated. This causes a read of the root query, and I think the problem is that using db->tree in my read is taking enough time that the delay is noticeable (I am using the default db format and using links to each line item from the parent record). If I only load up a record with 20 lines, everything is faster. Here's a simple example that shows the problem: https://github.com/caleb/om-input-perf-example/blob/master/src/perf/core.cljs Is there a different way I should be handling onChange?

wilkerlucio19:01:17

@caleb: you should try to avoid a full re-read when it's not nescessary, you can do that by placing idents at your line component, that way you can transact on it, making it refresh, avoiding a full re-read

caleb19:01:02

Hmm, I have an ident on my StatementLine component, but my read function is still being called on the parent key (`:current/statement`)

caleb19:01:03

And I’m being sure to call transact! with the StatementLine component. The good news is that it is not re-rendering the entire form (only the line item), but it is still doing a full read

andrewboltachev21:01:40

Hi. Can anyone tell what :pathopt option sent to reconciler means?

anmonteiro21:01:02

@andrewboltachev: :pathopt refers to path optimization

anmonteiro21:01:57

It's there to prevent a whole re-render when only a certain part of your ui transacts

anmonteiro21:01:29

Look into the NormTree example in the Om devcards to see how it works

andrewboltachev21:01:56

@anmonteiro: thanks, and NormTree is exactly what I'm looking at

anmonteiro21:01:20

@andrewboltachev: so, in particular, look at the read method with dispatch key :node/by-id, this is where the magic happens

andrewboltachev21:01:33

yep, I noticed that

andrewboltachev21:01:42

Wouldn't it work w/o it?

anmonteiro21:01:49

:query-root there is set to the ident of the node that transacted

anmonteiro21:01:17

I mean, the example would work without it, sure, if you set pathoptto false

andrewboltachev21:01:22

also, IIRC, tutorial says "we have to provide read functions"

andrewboltachev21:01:43

(in case we're implementing om/Ident)

anmonteiro21:01:06

not sure what you mean there

anmonteiro21:01:09

and I don't think it's true

andrewboltachev21:01:27

"Note that in this case we must supply read functions..."

anmonteiro21:01:47

@andrewboltachev: that refers to having to convert normalized data to the data we expect in our UIs

anmonteiro21:01:09

e.g. using db->tree

andrewboltachev21:01:21

but here done manually, right?

anmonteiro21:01:41

right. the tutorial was written before db->tree simple_smile

andrewboltachev21:01:35

anyway, where to dig if I face Uncaught #error {:message "No queries exist for component path (ex0001.core/App ex0001.core/AnimalsList)", :data {:type :om.next/no-queries}}?

andrewboltachev21:01:59

(version is last one, updated couple of hours ago)

anmonteiro21:01:44

@andrewboltachev: there could be a number of reasons, if you put it in a gist I can look at it really quick

nano21:01:13

So what to do about the root component not re-rendering after the cb has been called with new data in the reconciler's :send function?

anmonteiro21:01:26

@andrewboltachev: how do I trigger the problem=?

andrewboltachev21:01:03

uhm... let me rather push the repo then

anmonteiro21:01:42

your queries must compose to the root

anmonteiro21:01:55

your PerspectiveSwitch component declares queries

anmonteiro21:01:06

that never get to the App component

andrewboltachev21:01:38

so, in other words "parent" components must include all their children queries?

nano21:01:13

Is there any nice way for the root component of handling child query parameters other than dissecting the query via query->ast?

andrewboltachev22:01:06

@anmonteiro: but query of PerspectiveSwitch is [:perspectives/list :perspectives/active] and query of App includes it: [{:categories/list [:db/id :category/name {:category/_parent ...}]} :app/title (:animals/list) :selected/animal :perspectives/list :perspectives/active]

andrewboltachev22:01:47

Do you mean that it should rather look like {:perspective-switch <something>}?

anmonteiro22:01:47

@andrewboltachev: right, but the App component is using that query as its own

anmonteiro22:01:58

yes, it needs to be under a map key

anmonteiro22:01:34

@nano: 1st question: I'd start by looking if the app state gets properly updated

anmonteiro22:01:38

and go from there

anmonteiro22:01:55

@nano: 2nd question: haven't figured something out since you last asked that one

nano22:01:59

Humm.. I realized I had seen query-template mentioned here a while back, and found it in the tests.

anmonteiro22:01:12

@nano: query template is useful but it's private simple_smile

anmonteiro22:01:55

@nano: it's more of a utility thing that returns a zipper

nano22:01:46

1st question, app-state is being updated correctly when inspected in the repl, and if I reload my browser to get to the main page again, and enter the child component I selected last time, it will then display the already fetched data.

anmonteiro22:01:34

that's really odd because merge! queues the incoming keys for re-render

nano22:01:06

and merge! is something that's called via the cb passed to the :send function?

anmonteiro22:01:44

merge! is exactly what the cb is simple_smile

nano22:01:30

ah, maybe i should just bite the bullet and start reading more source code instead of sticking with the documentation.

andrewboltachev22:01:32

is it the right form of query for child component now?

andrewboltachev22:01:35

feel like not understandind at all how co-located queries work 😐

anmonteiro22:01:50

@andrewboltachev: it is, but you should be using get-query so that Om can calculate the paths

andrewboltachev22:01:15

ah, so, probably metadata matters here

anmonteiro22:01:29

just think of it like a modularity thing

anmonteiro22:01:56

and the Root being where all your "modules" meet each other

anmonteiro22:01:14

because when you add-root!, Om only has knowledge of one component, the Root

anmonteiro22:01:36

it must descend the query paths in order to be knowledgeable of the other components

anmonteiro22:01:46

i.e. your UI is a tree

anmonteiro22:01:56

but you already knew that

andrewboltachev22:01:20

so, now when it looks for :perspective-switch, my read fn must return {:perspectives/list <...> :perspectives/active <...>}

anmonteiro22:01:13

I don't know, I haven't looked at anything besides the queries simple_smile

isak22:01:33

i went through the om/next "Components, Identity & Normalization" demo and tried to add a remove button to remove a person from a list, but i'm getting a problem where the RootView/ListView do not update, so the deletion isn't shown even though the app state updates correctly

anmonteiro22:01:34

but I suppose so, if those are the keys in the join

isak22:01:38

anyone know what is wrong?

andrewboltachev22:01:19

@anmonteiro: I mean it looks like duplication

anmonteiro22:01:24

@isak: depends where you're transact!ing; you might just need to add a key to be re-read after transact!

andrewboltachev22:01:54

i.e. read fns duplicates what IQuery tree already knows about

anmonteiro22:01:00

@andrewboltachev: so that might be because you have structured your things the wrong way

anmonteiro22:01:34

there can always exist components that don't have queries!

isak22:01:06

ok, i'll look into that, thanks

andrewboltachev22:01:18

@isak also feel free to post your core.cljs file, as many others here went through the tutorial also

andrewboltachev22:01:25

@anmonteiro: quick question: is it wrong to pass whole (om/get-props this) thing to a child component (say, when it uses the same data what parent is, i.e. when parent also does using the data)?

anmonteiro22:01:01

@andrewboltachev: it kinda smells from where I stand

anmonteiro22:01:16

I'd look into having a better structure of your app-state / UI components

anmonteiro22:01:49

as in, try to understand where things fit; start with a small example and go from there

isak22:01:40

@andrewboltachev: @anmonteiro : the tip about adding keys to reread with the transact call solved my issue, thanks!

andrewboltachev22:01:28

@isak: cool! thanks to @anmonteiro actually. I think it's important to have ppl to succes with tutorials and do more attempts to solve problems with Om Next

isak22:01:04

from the docs I see that is also possible to provide a hint about what keys are affected in the mutate function itself, but that it does not affect re-rendering

isak22:01:46

does anyone know why it doesn't affect re-rendering? i'm worried that specifying it in the transact calls could lead to repetition

isak22:01:05

like if you have one mutation you want to run from 5 places in your app - it seems like you'd also need to specify the other keys affected in all those 5 places

andrewboltachev22:01:28

do you mean :value :keys ?

anmonteiro22:01:42

@isak: the :keys in the mutation's value is sort of a documentation thing

anmonteiro22:01:16

@isak: if you're worried about repetition then just create a function that receives a component instance and performs the transact! call. Then you only write the keys to be re-read once simple_smile

anmonteiro22:01:59

no one ever said that transact! needs to be directly invoked

isak22:01:27

thats true, though it seems like a missed opportunity, unless there is something i'm not getting

andrewboltachev22:01:48

@anmonteiro: won't :value :keys work on the server also?

anmonteiro22:01:17

@andrewboltachev: depends on what you mean by "work"

anmonteiro22:01:30

they are supported, yes; they won't do anything, though. As I said, they are there just to provide documentation

andrewboltachev22:01:37

so "supported" means there wouldn't be any error message, then

andrewboltachev22:01:15

'[:name :points] from 2nd snippet also for documentation purposes?

anmonteiro22:01:54

sorry where?

andrewboltachev22:01:14

query part of defui Person

anmonteiro22:01:36

it's not for documentation purposes if it's an implementation of IQuery

andrewboltachev22:01:42

I mean not for Person on itself, but in this particular case

anmonteiro22:01:14

No, in that case it actually serves a purpose

anmonteiro22:01:58

the fact that there are no render methods doesn't mean anything; the IQuery implementations (along with the Ident ones) in that case have the purpose of telling Om how to normalize the data

andrewboltachev22:01:01

ah, there's get-query Person just below

andrewboltachev22:01:17

though, anyway, what function would receive there as parameters?

andrewboltachev22:01:11

I mean read-fn only obtains :list-one and :list-two keys, isn't it?

andrewboltachev22:01:55

huh, it should rather obtain whole sub-query as a key

andrewboltachev22:01:15

dunno if that's right thinking

anmonteiro22:01:22

even if you don't call it explicitly, the reconciler will normalize the data for you when you add-root!

andrewboltachev22:01:41

oh, that answers one of my first questions

andrewboltachev22:01:32

with tree->db I should get rid of duplication I were afraid of

andrewboltachev23:01:06

I hope you understand what I'm talking about, and it's something useful not meaningless 😄

andrewboltachev23:01:51

also, a thing about idents it that ident fn doesn't know the name of the key which is unique

andrewboltachev23:01:26

thus it isn't removed from map of normalized things

andrewboltachev23:01:00

:person/by-name
 {"John" {:name "John", :points 0}
; the rest}

tyler23:01:02

Should data be normalized when it is returned from a remote source and passed into the callback from the send function?

tyler23:01:49

it looks like it gets normalized but I can’t see the refs in the metadata

andrewboltachev23:01:50

@tyler: does this issue break something?

tyler23:01:28

not sure what you mean by break something. And I’m not sure if its an issue or I’m just incorrect in my implementation

tyler23:01:47

say my remote returns: {:quay/images [{:name aat} {:name agronomy} {:name billing} {:name core} {:name weather}]}

tyler23:01:04

and I call callback from the send fn with that edn data

tyler23:01:10

what is the expected behavior

tyler23:01:19

should the refs be added to the metadata of state?

andrewboltachev23:01:40

@tyler: from what I know, read-fns always return data in "end-user" form

andrewboltachev23:01:20

"Note that in this case we must supply read functions - our data will be normalized so we have to build the original tree form."

andrewboltachev23:01:36

so, read-fn is to return "original tree form"

andrewboltachev23:01:47

I haven't worked with remote parsers so I don't know for sure

andrewboltachev23:01:23

IIRC David also said "parser is the thing we put into cljc file", so it should be no different then

andrewboltachev23:01:55

@tyler: just in case check what version of om you're on and try on latest one from master

nano23:01:32

@anmonteiro: Guessing here, but I think that it might have to do with my hacking the params into the query. That way the query loses its meta. If I hardcode the params into the child, and use the original child component query, the changing of the child component works as expected. Haven't read up on the source, not sure where to start digging really.