Fork me on GitHub
#om
<
2017-03-03
>
qqq00:03:08

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

qqq00:03:43

got it all working!

anmonteiro01:03:21

you’re correct

anmonteiro01:03:44

but the error will be in the return of transact!

anmonteiro01:03:52

because transact! calls the parser

qqq02:03:52

@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 ?

anmonteiro02:03:55

the errors are caught in the parser so that every transaction can run to the end

qqq02:03:53

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 ]

anmonteiro02:03:42

@qqq so you can probably throw in the parser by throwing an exception-info with {:type :om.next/abort}

qqq02:03:49

@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

qqq05:03:46

========== 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.

anmonteiro05:03:33

@qqq you can call transact! on the reconciler

qqq05:03:11

@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?

qqq05:03:46

oh, it works now

qqq05:03:52

my typo was from elsewhere; thanks !

matthavener14:03:30

qqq: FWIW, in chrome dev tools you can specify opening the debugger even for “caught” exceptions

qqq14:03:07

yeah, but quite a few libraries use "caught" exceptions as control flow

qqq14:03:21

which unforunately negates the debug technique @matthavener

matthavener14:03:33

yeah, there are two in the closure library startup

qqq14:03:40

but (js-debugger) is nice -- can't be caught, and pops me directly into debugger

matthavener14:03:15

yeah that sounds really nice. I’ll have to try that sometime. reminds me of asserting or int *p = 0; *p = 1; in C++

qqq14:03:58

oh, for C++, 99% of my errors were reading uninitialized, writing out of bounds, so valgrind was life saver

peeja21:03:00

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]}]

qqq21:03:06

if I'm using datascript as my db, and I'm not doing remotes; does om offer anything over reframe ?

anmonteiro21:03:38

let me re-read the post

anmonteiro21:03:37

@peeja hrm OK so the first one is correct

anmonteiro21:03:04

it’s also what David showcased in one of the earliest Om Next talks https://pbs.twimg.com/media/CQzq8FrW8AAG_lP.png:large

anmonteiro21:03:17

the second one could work 🙂

anmonteiro21:03:23

but I don’t know if it will

anmonteiro21:03:47

basically the difference is in 1) you’re parameterizing the join, in 2) you’re parameterizing the join key

peeja21:03:11

Oh, I guess that makes sense…

peeja21:03:35

The first one seems more readable to me, with the assumption that subqueries grow larger than param maps

anmonteiro21:03:09

@peeja is the big Om Next migration still underway? 🙂

anmonteiro21:03:17

I’m interested to know how it’s going

peeja21:03:37

Yeah, I'm trying to work out the best way to query for deeply nested stuff ATM

peeja21:03:10

@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"}})]}]

peeja21:03:56

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.

anmonteiro21:03:06

2 feels weird

anmonteiro22:03:31

why not just:

[({[:build/by-whatever-it-needs-to-be x] [:.....]} {:params here})]

petterik22:03:42

I've run in to problems using [{(:key {:params here}) [:foo]}] in earlier versions of om.next. Since then I've stuck to [({:key [:foo]} {:params here})] and had no problems