om

Please ask the channel first, not @dnolen directly!
sophiago 2017-05-28T04:30:21.222478Z

i was going to wait until tomorrow to ask this, but while i'm on here troubleshooting something...is there a best practice with Om.Next for querying the DOM after components mount? i.e. code you'd put inside componentDidMount if using straight React? particularly, i need the context of canvas elements and it doesn't seem to be working if i created it and call (.getContext (.getElementById ...) ...) in the same function, which makes sense. but i'm not sure i understand how the reconciler works well enough to know for sure

2017-05-28T07:39:56.600727Z

david, thx for the answer

2017-05-28T11:07:36.063643Z

sophiago: usually for canvas you can render the canvas element in render and attach a ref to it: https://facebook.github.io/react/docs/refs-and-the-dom.html

2017-05-30T00:26:47.171240Z

hey, just saw your message - i don't follow this code, did it end up working?

2017-05-30T00:27:53.176559Z

I don't see how the ctx in your example is getting passed down

sophiago 2017-05-30T03:12:52.110599Z

i actually had a really full day so didn't get to work on this. your code made sense just from the snippet, but the difference is i want to have the context in the store since i'm drawing to it from regular cljs functions (i'm trying to refactor a project that currently uses a hardcoded canvas because i realized it made more sense to use several of them generated on the fly)

sophiago 2017-05-30T03:16:29.130537Z

perhaps i should just call swap! inside componentDidMount? i figured i could maybe assoc it through however the defui macro assocs the keys, but am not sure if that even works slash what the correct syntax would be to do it

2017-05-31T12:27:28.244996Z

hey, seems like the confusion is mainly around the om way of doing things. it will probably help a lot to go through the om tutorials. tony kay (of untangled) has a really helpful one: https://github.com/awkay/om-tutorial

sophiago 2017-05-31T21:54:42.972800Z

Thanks, I'll look into it. I think I've been using Om in a kind of hacky way so far, especially since I usually want to integrate it into a larger library. Like in another version of this library I just call swap! on the store with data for my one key and it creates new elements from a factory. It works, but surely can't be the ideal way of doing things and now that I'm trying something more complicated it's creating trouble.

2017-05-28T11:07:44.063916Z

then grab the ref in didmount or did update

sova-soars-the-sora 2017-05-28T16:22:04.923072Z

Also, just a general clojurescript gotcha is the (-.javascriptstuff ... ... ...)

pedroteixeira 2017-05-28T17:56:34.211620Z

trying on master currently see the following error

➜  om git:(master) lein cljsbuild once hello
Compiling ClojureScript...
Compiling "examples/hello/main.js" from ["src" "examples/hello/src"]...
Compiling "examples/hello/main.js" failed.
clojure.lang.ExceptionInfo: failed compiling file:examples/hello/out/cljs/pprint.cljs {:file #object[java.io.File 0x1bff5ad0 "examples/hello/out/cljs/pprint.cljs"]}
...
Caused by: clojure.lang.ExceptionInfo: Invalid :refer, macro cljs.pprint/deftype does not exist in file examples/hello/out/cljs/pprint.cljs {:tag :cljs/analysis-error}

👁️ 1
pedroteixeira 2017-05-28T17:57:37.214762Z

it does not seem specific to Om, but wanted to check here first

sova-soars-the-sora 2017-05-28T20:36:17.706654Z

@pedroteixeira any headway ?

pedroteixeira 2017-05-28T21:11:31.818529Z

no, but boot devcards is working. i posted on #clojurescript about the 'deftype does not exist'

sophiago 2017-05-28T21:53:06.936415Z

dvingo: hey, i remember meeting you at the NYC Clojure meetup! i'm unclear what you're suggesting here, though. i know how to do this using the React API, but am wondering how to reconcile that (sorry for the pun) with Om.Next. iow, would it be enough to just update props in one function in order to render the canvas and then grab the context in another (as opposed to doing it in one shot inside a do block)?