Fork me on GitHub
#om
<
2016-02-08
>
drcode00:02:15

@currentoor: The best "batteries included" example of remote syncing I know of (that is also up to date) is https://github.com/jdubie/om-next-starter

currentoor01:02:23

it looks like that one was last updated in late october

currentoor01:02:58

but no backend in that one

drcode01:02:30

@currentoor: Good point, but it still seems to run against latest alphas, last I tried

tony.kay03:02:09

@currentoor: @drcode There is a simulated back end...which is coded identically if you're trying to understand Om. But true that it does not start a real server. I will get back to it when I get time...been working on a more complete batteries included framework that I hope we open-source soon.

drcode03:02:38

Who is "we"? :)

tony.kay03:02:25

Me and my team...at work

tony.kay03:02:54

we've put together a full stack set of libraries based on Om...server and client...helper libraries, testing utils, etc.

tony.kay03:02:09

that's why I've not had time to touch the tutorial

drcode03:02:01

Sounds pretty awesome, looking forward to it!

currentoor06:02:08

@tony.kay: That sounds awesome. No pressure but any ideas when you’ll open source it?

currentoor06:02:27

Also are you currently using Om.next in production?

hueyp06:02:29

agreed on the awesome part simple_smile

hueyp06:02:25

heh, have a remote return {:current-user {:todosCount 1}} and my app-state goes from {:current-user [:person/by-id 1]} to {:current-user {:todosCount 1}} 😜

currentoor06:02:09

@tony.kay: this tutorial is pretty great by the way. Thanks for putting it together!

adamkowalski06:02:09

How are you guys dealing with the 300ms delay on click events in mobile browsers with Om Next

adamkowalski06:02:25

As I understand it each event can either trigger or not trigger a mutation

adamkowalski06:02:45

but if I have both a on-click and on-touch-end event wont my events fire multiple times?

hueyp07:02:06

got a remote todo example working, but what I’m doing in transact! is total trial / error on seeing how to keep the state in sync

steveb8n07:02:43

@hueyp: take a look at https://github.com/stevebuik/om-next-ideas for more examples of remote sync

steveb8n07:02:17

sync (read and mutate) works in cljs and with a clj integration test

steveb8n07:02:47

@hueyp: n.p. your blog posts on graphql last year helped me do a talk at clj-syd. just returning the favour simple_smile

hueyp07:02:17

interesting take on send! … I had sorta wondered about that, like it could be beneficial to have mutate + reads bundled together so you can change one place and all your components benefit

hueyp07:02:54

I’ll need to go through this … it ended up the only way I could get my state updating with default om stuff (merge-tree, etc) was to have reads tied to idents … e.g. [(todo/toggle {:id ~id}) {[:todo/by-id id] [:completed?]}] … if I just do [(todo/toggle {:id ~id}) :completed?] then the merged state just overwrites everything (but the send query is totally fine)

steveb8n07:02:32

agreed. the other non-conventional thing is it doesn’t use db->tree since it’s not cljc. writing the impls for reads accidentally taught me very clearly how idents work. db->tree is a little bit magic and in some ways I think that it makes idents a bit harder to learn

hueyp07:02:59

about every hour I go back and forth on whether writing your own impl’s for that stuff is good or bad idea

hueyp07:02:10

like the way idents are treated sometimes … I don’t understand it

steveb8n07:02:55

tony’s tutorial has a sentence in it that gave me “permission” not to use db->tree, that helped

hueyp07:02:05

I know that exact sentence

steveb8n07:02:28

being able to integration test before using it in the client turned out to be a great workflow

hueyp07:02:41

the final app state … doesn’t work so well 😜

hueyp07:02:14

but if I anchor the reads with an ident in the transact, its fine

steveb8n08:02:17

yeah that’s messed up. because I wrote my own fns for send, merge etc I don’t think I can help much

hueyp08:02:06

you are giving me permission, just like tony!

hueyp08:02:03

but if I do anchor it, it works, and my app state is updated and my components render well, and it makes me happy

hueyp08:02:14

the simple things

hueyp08:02:22

changing a ‘true’ to ‘false'

hueyp08:02:28

on a todo

steveb8n08:02:00

yep, there’s quite a few ways where small changes create unexpected behaviour. I’d predict that schema or something like it will become commonplace to avoid those cases. I have rudimentary examples in the ideas project but only for query

iwankaramazow09:02:16

@tony.kay: do you got to the point of server-side-rendering with your team?

Pablo Fernandez11:02:37

I’m getting an error, “Cannot read property ‘call’ of undefined” on next.cljs:1598 (https://github.com/omcljs/om/blob/1.0.0-alpha30/src/main/om/next.cljs#L1598). It looks like system-time is not defined and I’m not sure, looking at that file, where it should be coming from.

Pablo Fernandez11:02:50

I’m using Om alpha30.

Pablo Fernandez11:02:10

Does anybody know what’s going on here?

anmonteiro11:02:53

@pupeno: system-time is in cljs.core

anmonteiro11:02:14

which clojurescript version are you using?

Pablo Fernandez11:02:17

cljs.user=> (system-time) WARNING: Use of undeclared Var cljs.user/system-time at line 1 <cljs repl> #object[TypeError TypeError: Cannot read property 'call' of undefined]

Pablo Fernandez11:02:51

I’m at 1.7.48. The latest didn’t work for me, so I didn’t upgrade.

anmonteiro11:02:09

@pupeno: system-time was introduced in 1.7.145

Pablo Fernandez11:02:16

Argh. Ok. thanks.

anmonteiro11:02:22

you should update CLJS

anmonteiro11:02:36

the fact that it didn't work for you might be related to the fact that you need to update your tooling

anmonteiro11:02:46

e.g. lein-cljsbuild, figwheel and the likes

anmonteiro11:02:48

this is only true for cljs >= 1.7.170. you can always run 1.7.145 without upgrading tooling and get system-time

Pablo Fernandez11:02:58

I am running the latest lein-cljsbuild and the latest lein-figwheel. I think I found the problem. Dependencies was updated, but plugins wasn’t.

anmonteiro11:02:28

plugins are also tooling

Pablo Fernandez11:02:24

I’m getting a similar behaviour on 1.7.228.

Pablo Fernandez11:02:42

Analyzing jar:file:/Users/pupeno/.m2/repository/org/clojure/clojurescript/1.7.228/clojurescript-1.7.228.jar!/cljs/pprint.cljs
Copying jar:file:/Users/pupeno/.m2/repository/org/clojure/clojurescript/1.7.228/clojurescript-1.7.228.jar!/cljs/pprint.cljs to resources/public/js/app/cljs/pprint.cljs
Compiling resources/public/js/app/cljs/pprint.cljs
To quit, type: :cljs/quit
cljs.user=> (system-time)
#object[TypeError TypeError: Cannot read property 'call' of undefined]
TypeError: Cannot read property 'call' of undefined
    at eval (eval at figwheel$client$utils$eval_helper (), <anonymous>:1:110)
    at eval (eval at figwheel$client$utils$eval_helper (), <anonymous>:9:3)
    at eval (eval at figwheel$client$utils$eval_helper (), <anonymous>:14:4)
    at figwheel$client$utils$eval_helper ()

anmonteiro11:02:00

@pupeno: which figwheel version are you using?

Pablo Fernandez11:02:44

I’m getting some other errors too.

anmonteiro11:02:00

did you clean your build?

Pablo Fernandez11:02:15

Let me verify that, just in case.

Pablo Fernandez11:02:00

Yes, it was a clean build.

anmonteiro11:02:04

in any case if that doesn't work, make sure that lein deps :tree is not overriding anything

Pablo Fernandez11:02:20

Version looks fine, but I wonder if the recommended exclusion is pointing to a potential problem: https://gist.github.com/pupeno/676827af2c51fbe00487

anmonteiro11:02:46

@pupeno: you have a lot of conflicts there

anmonteiro11:02:39

I'd start by migratus-lein

anmonteiro11:02:50

seems because it depends on clojure 1.6 it is overriding a lot of stuff

Pablo Fernandez11:02:07

wow, this is a mess.

Pablo Fernandez11:02:59

Clojure 1.6 is also requested through: [lein-ancient "0.6.7"] -> [version-clj "0.1.2"] -> [org.clojure/clojure "1.6.0"]

Pablo Fernandez11:02:43

It seems my version of ClojureScript is used anyway.

iwankaramazow11:02:52

I assume there is no way around passing props down even if certain components don't need them? E.g. history and a function (.setToken history token), to trigger a routing transitions...

danielstockton11:02:58

wouldn't you just transact a route change in the state and have the root component set the url based on that?

martinklepsch11:02:56

Q reagarding Om Now — many react components have special handling for children being passed into the component — is there documentation how to use these components with Om?

iwankaramazow11:02:10

@danielstockton: a mutation should be side-effect free, shouldn't it?

martinklepsch11:02:26

found this which seems to indicate it's not possible and won't be possible any time soon: https://github.com/omcljs/om/issues/291

danielstockton11:02:39

@iwankaramazow: Why would it not be? mutation just sets :route to :home in the state, root component checks :route in willMountUpdate and sets the token based on that

iwankaramazow12:02:15

@danielstockton: so blocking the standard behavior of dom/a with preventdefault and manually triggering a history transition with (.setToken history token) is pointless?

iwankaramazow12:02:34

I thought this was necessary to prevent a page-reload

iwankaramazow12:02:55

and letting React perform it's dom diffing magic

iwankaramazow12:02:24

I could be completely wrong

danielstockton12:02:15

actually, you would need to block the standard behaviour somehow

danielstockton12:02:19

i'll let someone with more experience answer 😛

rburns12:02:48

how do you go about enabling the internal logging in om.next?

anmonteiro13:02:26

@rburns: pass a compatible goog.log to the :logger key in the reconciler

rburns14:02:37

passing :logger (getLogger "my-logger") to the reconciler (getLogger from the goog.log namespace) doesn't produce any additional output. I'm guessing I'm still missing something

anmonteiro14:02:25

@rburns: which log messages are you looking to be shown specifically?

anmonteiro14:02:15

this should be shown by default

anmonteiro14:02:24

you don't need to pass a logger

rburns14:02:52

more specifically looking for information about https://github.com/omcljs/om/blob/master/src/main/om/next.cljs#L1126 being thrown as a result of set-query!

anmonteiro14:02:22

I'd check a few things out: 1. make sure your components are not stealing queries from each other 2. if 1. holds, make sure you're running the latest Om master, since there was a fix wrt. to this since the alpha30 release

rburns14:02:37

@anmonteiro: should they show up in the console? I've run lein install from om git. would that build maybe behave differently?

anmonteiro14:02:41

@rburns: if you're running the latest master already, check 1?

anmonteiro14:02:00

I'm also happy to look at a minimal case that demonstrates the issue you're having

rburns14:02:29

will put together a gist

rburns14:02:15

https://gist.github.com/rburns/176d8014481ef903f804 that's maybe not enough. but, as regards stealing queries, the only thing that is maybe suspect is that the :route key appears in a parent query as well.

anmonteiro14:02:22

@rburns: the gist doesn't really show anything useful

anmonteiro14:02:40

I was more interested in seeing the query structure, of the component hierarchy

anmonteiro14:02:59

but if you say that :route is also in a parent query, the stealing might be there

rburns14:02:30

thanks for the hint. I can continue digging.

anmonteiro14:02:42

your queries have to compose

anmonteiro14:02:06

if you have :route in a parent and :route in a child

anmonteiro14:02:10

that's going to cause problems

rburns14:02:13

does that mean, in the case that you want the same information in multiple places in the tree, then you need multiple identifiers for it in the query?

anmonteiro14:02:01

either that, or use Links

anmonteiro14:02:45

I'd say Links are the way to go

anmonteiro14:02:10

if you haven't, go through this tutorial

anmonteiro14:02:16

(and all others, for that matter)

rburns14:02:15

I've been through that one, and these https://awkay.github.io/om-tutorial/ they were all quite helpful

tony.kay15:02:18

@iwankaramazow: server-side rendering: no...don't need it, and probably won't.

Pablo Fernandez17:02:08

My apologies for the basic question, but I’m getting this error: "Uncaught Error: Assert failed: route/update mutation :value must be nil or a map with structure {:keys [...]} (or (nil? value) (map? value))” on this line: https://github.com/jdubie/om-next-router-example/blob/master/src/om_router/core.cljs#L130

Pablo Fernandez17:02:03

What’s wrong? isn’t arguments free form?

hugod18:02:48

@dnolen: fwiw, to use a ReactNative ListView with om.next, I had to bind the om dynamic vars, and manually propagate the props meta-data: https://gist.github.com/hugoduncan/2bd2d57b7eb42dc7b740

dnolen18:02:57

@hugod right, that scenario is to be expected if you have to pass some view factory for something else to render

dnolen18:02:21

could easily provide some kind of standard helper for this case ...

adamkowalski18:02:53

I would like to make a component to practice working with event streams but I don’t quite know how I am supposed to approach this. Lets say I would like a rectangle, which begins at the top left corner of the screen, and whose bottom right corner is always the same as the mouse coordinates.

adamkowalski18:02:47

I was thinking that somehow every time the mouse position changes I would be able to trigger a transaction whose payload would be the current coordinates of the mouse, then I could use that information to update the app state which would contain the dimensions of the rectangle.

anmonteiro18:02:17

@adamkowalski: you can definitely do that with component local state

anmonteiro18:02:29

there's an example in Om's devcards which might help you get started

adamkowalski18:02:27

interesting, thanks for the idea

adamkowalski18:02:10

could i make it so it is not tied to a single component and listen to the document on mouse move event instead?

adamkowalski18:02:24

how in clojurescript would I do something like this document.onmousemove = function(e){ console.log(e); } I tried doing (.onmousemove js/document (fn [e] (.log js/console e)))

jr18:02:21

(set! js/document .-onmousemove (fn [e] …)

jr18:02:48

that’s how you assign properties on js objects in cljs

adamkowalski18:02:39

(set! js/document .-onmousemove (fn [e] (.log js/console e)))

adamkowalski18:02:45

I tried that and I get an error

adamkowalski18:02:06

set! target must be a field or a symbol naming a var

jr19:02:46

ah yeah the arguments were wrong in my example

jr19:02:06

(set! (.-onmousemove js/document) (fn [e] …)

adamkowalski19:02:42

awesome! thank you

adamkowalski19:02:09

ok I got it to work (set! (.-onmousemove js/document) (fn [e] (om/transact! reconciler `[(mouse {:x (.-x e) :y (.-y e)})])))

adamkowalski19:02:19

but is transact meant to be called so many times in succession? because now when I open up the console it almost immediately fills with a log of uuids

cjmurphy21:02:35

I was doing a very similar thing to you. To get rid of those you can set the reconciler's :logger to nil.

cjmurphy21:02:32

Or take a look [here](https://github.com/chrismurrph/om-alarming/blob/master/src/om_alarming/reconciler.cljs) where did something slightly better than setting it to nil.

cjmurphy21:02:40

I suspect it will be fast enough to handle mouse events. But we should probably both switch to using local state for the mouse-while-being-moved position, unless it really is needed elsewhere in the application.