This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-08
Channels
- # aatree (3)
- # announcements (1)
- # architecture (5)
- # beginners (27)
- # boot (22)
- # cider (17)
- # cljsrn (8)
- # clojure (93)
- # clojure-canada (1)
- # clojure-dev (7)
- # clojure-nl (10)
- # clojure-poland (216)
- # clojure-russia (35)
- # clojurescript (163)
- # community-development (6)
- # cursive (25)
- # datavis (6)
- # datomic (18)
- # dirac (10)
- # dysphemism (4)
- # editors (3)
- # editors-rus (1)
- # emacs (15)
- # hoplon (124)
- # instaparse (25)
- # jobs (10)
- # ldnclj (78)
- # lein-figwheel (11)
- # leiningen (6)
- # off-topic (20)
- # om (149)
- # onyx (2)
- # parinfer (5)
- # portland-or (1)
- # proton (62)
- # quil (2)
- # re-frame (8)
- # spacemacs (4)
- # yada (20)
@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
@drcode: thanks!
it looks like that one was last updated in late october
this one looks more recent https://github.com/awkay/om-tutorial
but no backend in that one
@currentoor: Good point, but it still seems to run against latest alphas, last I tried
@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.
we've put together a full stack set of libraries based on Om...server and client...helper libraries, testing utils, etc.
@tony.kay: That sounds awesome. No pressure but any ideas when you’ll open source it?
Also are you currently using Om.next in production?
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}}
😜
@tony.kay: this tutorial is pretty great by the way. Thanks for putting it together!
How are you guys dealing with the 300ms delay on click events in mobile browsers with Om Next
As I understand it each event can either trigger or not trigger a mutation
but if I have both a on-click and on-touch-end event wont my events fire multiple times?
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
@hueyp: take a look at https://github.com/stevebuik/om-next-ideas for more examples of remote sync
@hueyp: n.p. your blog posts on graphql last year helped me do a talk at clj-syd. just returning the favour
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
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)
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
about every hour I go back and forth on whether writing your own impl’s for that stuff is good or bad idea
tony’s tutorial has a sentence in it that gave me “permission” not to use db->tree, that helped
being able to integration test before using it in the client turned out to be a great workflow
heres path from start to end : https://gist.github.com/eyston/7f870671e00067020b00
yeah that’s messed up. because I wrote my own fns for send, merge etc I don’t think I can help much
but if I do anchor it, it works, and my app state is updated and my components render well, and it makes me happy
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
@tony.kay: do you got to the point of server-side-rendering with your team?
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.
I’m using Om alpha30.
Does anybody know what’s going on here?
@pupeno: system-time
is in cljs.core
which clojurescript version are you using?
Is that new?
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]
I’m at 1.7.48. The latest didn’t work for me, so I didn’t upgrade.
@pupeno: system-time
was introduced in 1.7.145
Argh. Ok. thanks.
you should update CLJS
the fact that it didn't work for you might be related to the fact that you need to update your tooling
e.g. lein-cljsbuild, figwheel and the likes
this is only true for cljs >= 1.7.170. you can always run 1.7.145 without upgrading tooling and get system-time
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.
plugins are also tooling
I know.
I’m getting a similar behaviour on 1.7.228.
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 ()
@pupeno: which figwheel version are you using?
0.5.0-6
I’m getting some other errors too.
did you clean your build?
Let me verify that, just in case.
Yes, it was a clean build.
in any case if that doesn't work, make sure that lein deps :tree
is not overriding anything
Version looks fine, but I wonder if the recommended exclusion is pointing to a potential problem: https://gist.github.com/pupeno/676827af2c51fbe00487
@pupeno: you have a lot of conflicts there
I'd start by migratus-lein
seems because it depends on clojure 1.6 it is overriding a lot of stuff
wow, this is a mess.
Clojure 1.6 is also requested through: [lein-ancient "0.6.7"] -> [version-clj "0.1.2"] -> [org.clojure/clojure "1.6.0"]
It seems my version of ClojureScript is used anyway.
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...
wouldn't you just transact a route change in the state and have the root component set the url based on that?
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?
@danielstockton: a mutation should be side-effect free, shouldn't it?
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
@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
@danielstockton: so blocking the standard behavior of dom/a
with preventdefault
and manually triggering a history transition with (.setToken history token)
is pointless?
I thought this was necessary to prevent a page-reload
and letting React perform it's dom diffing magic
I could be completely wrong
actually, you would need to block the standard behaviour somehow
i'll let someone with more experience answer 😛
@rburns: pass a compatible goog.log to the :logger
key in the reconciler
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
@rburns: which log messages are you looking to be shown specifically?
this should be shown by default
you don't need to pass a logger
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!
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
@anmonteiro: should they show up in the console? I've run lein install
from om git. would that build maybe behave differently?
@rburns: if you're running the latest master already, check 1?
I'm also happy to look at a minimal case that demonstrates the issue you're having
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.
https://gist.github.com/rburns/176d8014481ef903f804#file-gistfile1-txt-L17 this will trigger the component has no query error
@rburns: the gist doesn't really show anything useful
I was more interested in seeing the query structure, of the component hierarchy
but if you say that :route is also in a parent query, the stealing might be there
your queries have to compose
if you have :route in a parent and :route in a child
that's going to cause problems
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?
either that, or use Links
I'd say Links are the way to go
if you haven't, go through this tutorial
(and all others, for that matter)
I've been through that one, and these https://awkay.github.io/om-tutorial/ they were all quite helpful
@iwankaramazow: server-side rendering: no...don't need it, and probably won't.
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
What’s wrong? isn’t arguments free form?
Figured it out.
@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
@hugod right, that scenario is to be expected if you have to pass some view factory for something else to render
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.
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.
@adamkowalski: you can definitely do that with component local state
there's an example in Om's devcards which might help you get started
https://github.com/omcljs/om/blob/master/src/devcards/om/devcards/bugs.cljs#L74-L112
interesting, thanks for the idea
could i make it so it is not tied to a single component and listen to the document on mouse move event instead?
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)))
(set! js/document .-onmousemove (fn [e] (.log js/console e)))
I tried that and I get an error
set! target must be a field or a symbol naming a var
awesome! thank you
ok I got it to work
(set! (.-onmousemove js/document)
(fn [e] (om/transact! reconciler `[(mouse {:x (.-x e) :y (.-y e)})])))
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
I was doing a very similar thing to you. To get rid of those you can set the reconciler's :logger to nil.
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.