This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-03
Channels
- # bangalore-clj (2)
- # beginners (29)
- # boot (52)
- # cider (4)
- # clara (3)
- # cljs-dev (34)
- # cljsjs (7)
- # cljsrn (3)
- # clojure (71)
- # clojure-austin (1)
- # clojure-dev (5)
- # clojure-france (20)
- # clojure-russia (51)
- # clojure-spec (9)
- # clojure-uk (20)
- # clojurescript (131)
- # core-async (56)
- # core-logic (6)
- # cursive (50)
- # datascript (19)
- # datomic (16)
- # dirac (118)
- # emacs (100)
- # events (4)
- # hoplon (14)
- # incanter (1)
- # jobs (7)
- # jobs-discuss (96)
- # jobs-rus (21)
- # lein-figwheel (5)
- # leiningen (21)
- # off-topic (11)
- # om (45)
- # onyx (42)
- # pamela (1)
- # pedestal (22)
- # portland-or (3)
- # re-frame (8)
- # reagent (5)
- # ring (9)
- # robots (1)
- # spacemacs (14)
- # specter (28)
- # sql (2)
- # untangled (165)
so I have something of the form
(let [ans (om/transact! ...)]
(if (:om.next/error ans)
(throw (:om.next/error ans)))
(. js/console log "ans: " ans))
unforcunately, I get the console log output, but I don't the exception thrown@anmonteiro : actually, I think https://github.com/omcljs/om/blob/f444a118da4ec263795ade49bfd7c4e1c3478b71/src/main/om/next/impl/parser.cljc#L281 is the line where the exception is being thrown / caught
you’re correct
but the error will be in the return of transact!
because transact!
calls the parser
@anmonteiro : I just realized, you're one of the git contributors to that file so I am rethrowing with
(let [ans (om/transact! ...)]
(when-let [err (get-in ans ['window/new :om.next/error])]
(throw err)))
the problem with this rethrow technique is that:
(1) it does get me the error msg of the original exception
(2) however, it doesn't get me (atleast in cljs-devtools) the stack frame of the original exception
suppose I take https://github.com/omcljs/om/blob/f444a118da4ec263795ade49bfd7c4e1c3478b71/src/main/om/next/impl/parser.cljc#L279-L284 ... and rip out the "catch" clause, what bad things should I expect to happen ?the errors are caught in the parser so that every transaction can run to the end
I can see how that is the right thing to do during production. During dev time, I want the transaction to die there, so I can debug it, save files, and have it reload. Is there some way, where instead of throwing an exception, I make a call to the browser (direclty from cljs land) so it triggers the debugger [ which won't be caught ] instead of throwing an exception [ which would be caught ]
@qqq so you can probably throw in the parser by throwing an exception-info
with {:type :om.next/abort}
follow this code path: https://github.com/omcljs/om/blob/master/src/main/om/next/impl/parser.cljc#L237
@anmonteiro : I'm not sure why this works, but it appears changing my
(assert (...)) ;; which the parser catches
to
`
(if-not (...)
(js-debugger))
(which jumps me right into the debugger)
has provided the desired behaviour========== If I have access to the reconciler, is there a way to directly call a mutate? Even if I'm outside of a OM UI Element? I feel like this should be doable but I can't figure out how to do it.
@qqq you can call transact!
on the reconciler
@anmonteiro I tried replacing:
(om/transact! this '[(foo/new)]
with
(om/transact! reconciler '[(foo/new)])
and I got some error ^^ did I use the right ocmmand, or did you have something else in mind?qqq: FWIW, in chrome dev tools you can specify opening the debugger even for “caught” exceptions
which unforunately negates the debug technique @matthavener
yeah, there are two in the closure library startup
yeah that sounds really nice. I’ll have to try that sometime. reminds me of asserting or int *p = 0; *p = 1;
in C++
oh, for C++, 99% of my errors were reading uninitialized, writing out of bounds, so valgrind was life saver
I'm looking at https://anmonteiro.com/2016/01/om-next-query-syntax/, which is > 1 year old now; it says that the read param syntax is
[({:some/key [:subkey/one :subkey/two]} {:some/param 42})]
Is that still true? I thought it was
[{(:some/key {:some/param 42}) [:subkey/one :subkey/two]}]
if I'm using datascript as my db, and I'm not doing remotes; does om offer anything over reframe ?
@peeja both valid
oh wait
let me re-read the post
@peeja hrm OK so the first one is correct
it’s also what David showcased in one of the earliest Om Next talks https://pbs.twimg.com/media/CQzq8FrW8AAG_lP.png:large
the second one could work 🙂
but I don’t know if it will
basically the difference is in 1) you’re parameterizing the join, in 2) you’re parameterizing the join key
The first one seems more readable to me, with the assumption that subqueries grow larger than param maps
agreed
@peeja is the big Om Next migration still underway? 🙂
I’m interested to know how it’s going
@anmonteiro Speaking of which: if you were going to ask the server for data (`[:...]`) about a particular build (`/gh/some-org/some-project/30`), would you construct the query as:
[{[:build/by-a-whole-lotta-stuff {:organization/vcs-type :vcs-type/github
:organization/name "some-org"
:project/name "some-project"
:build/number 30}]
[:...]}]
or:
[{[:organization/by-vcs-type-and-name {:organization/vcs-type :vcs-type/github
:organization/name "some-org"}]
[({:organization/projects
[({:project/builds
[:...]}
{:where {:run/number 30}})]}
{:where {:project/name "some-project"}})]}]
I feel like Om queries don't quite solve this problem well, but I may just not have my head in the right place yet.
2 feels weird
why not just:
[({[:build/by-whatever-it-needs-to-be x] [:.....]} {:params here})]