Fork me on GitHub
#om
<
2016-07-09
>
wilkerlucio00:07:48

there is some unexpected behaviour here when returning class references from a function, apparently if I call a function that returns an Om component, I lose the ability to calls it's static methods

wilkerlucio00:07:17

with the code above ^^^

wilkerlucio00:07:54

without advanced compilation it returns true on both cases, but on advanced it loses the static methods when the instance is returned from a function instead of direct access

anmonteiro12:07:23

@dnolen: what do you think about making default-migrate, default-merge-ident, default-merge-tree, default-ui->props and default-extract-errors public just like default-merge?

anmonteiro12:07:55

the rationale being that people who override these may still want call the default ones in their overridden implementation and add just a bit of functionality over them

anmonteiro14:07:32

let me know if you want me to push a release

cmcfarlen14:07:32

@anmonteiro: Great! Thanks! This change is probably worthy of a release, but not necessary for me atm.

cmcfarlen14:07:51

I'll try this out later, today is filled with outdoor chores!

cmcfarlen14:07:47

That reminds me though. What do you think about adding a check in set-route! and only transact if the route given is different than the current route?

dnolen15:07:21

@anmonteiro: I’m ok with that PR welcome

anmonteiro15:07:53

we actually don’t really return the result of parsing from transactions

anmonteiro15:07:24

so even though the errors are in the parsing result, they never get returned

dnolen15:07:52

that would be a simple bug

dnolen15:07:07

thought I had a test for that, we should add one

anmonteiro15:07:25

@dnolen: gotcha, I’ll submit a PR for that one too, could you reopen?

anmonteiro16:07:03

@dnolen: alright, submitted that PR that makes those fns public, a fix for the transact! result and one more small fix for path-meta

anmonteiro16:07:12

I promise those were the last ones today 😉

dnolen16:07:16

heh, cool thanks

hueyp17:07:32

@anmonteiro: so specify on a constructor fn gets elided in advanced?

anmonteiro17:07:31

@hueyp: it seems like that’s the case

hueyp17:07:00

good to know! I have been counting on that — I’ll have to look at the om workaround 🙂

anmonteiro17:07:01

I can’t really tell you more though, I just know that from reading that part of the code I linked

anmonteiro17:07:28

@hueyp: the Om workaround is really just constructing a JS object the the class’s prototype

hueyp17:07:47

yah, but it also means static interfaces need to be implement on the constructor & prototype

hueyp17:07:59

or maybe I’m misunderstanding

hueyp17:07:22

I’m probably misunderstanding 🙂

hueyp17:07:53

I’m not very prototype smart~

anmonteiro17:07:38

@hueyp: static protocols like IQuery and Ident are also specify!ed on the constructor, yeah

anmonteiro17:07:39

but these “static” things are just a workaround for being able to get-query of a thing before it has been instantiated

wilkerlucio21:07:14

@anmonteiro: thanks, but I'm not sure how to use that, just to be clear, my issue not with IQuery specifically, I use a custom protocol that I would like to call, and the instance of the class comes from a multi-fn, how can I go around that?

anmonteiro21:07:14

@wilkerlucio: why doesnt what I pasted work? Get the method from the prototype and call that?

wilkerlucio21:07:09

@anmonteiro: let me show you how I tried:

wilkerlucio21:07:31

the (implements? r/IRouteMiddleware comp) returns true, but the call doesn't work, it throws the error TypeError: Cannot use 'in' operator to search for 'omcljs$reconciler' in undefined

wilkerlucio21:07:19

the error stack is not helpful on this, I'm trying to explore a bit more here (but advanced compilation takes a while to do each try)

wilkerlucio21:07:34

ok, I figure that the first level call is working, but from the inside of my method I call (om/get-query this), and aparently on this case it's losing the static methods again, and at this second level the trick doesn't seems to work

wilkerlucio21:07:58

this is what the method looks like now (trying to use the trick, not working this time):

anmonteiro21:07:05

@wilkerlucio: I'd say that now you need to do the same at the call site of remote-query

wilkerlucio22:07:01

@anmonteiro: you mean the (r/remote-query) on the first snippet?

anmonteiro22:07:54

Oh you did that already

anmonteiro22:07:39

@wilkerlucio: Could you show the stack trace you're getting now and where?

anmonteiro22:07:04

Compile with :pseudo-names true in advanced if you're not doing that already

wilkerlucio22:07:36

ok, gonna have to change the compilation, just a min

anmonteiro22:07:26

@wilkerlucio: do you confirm that it only happens in advanced?

wilkerlucio22:07:44

@anmonteiro: yes, that code works correctly under other optimizations

wilkerlucio22:07:51

stack caused by:

wilkerlucio22:07:29

I created another snippet completing a minimal case:

wilkerlucio22:07:31

@anmonteiro: I noticed something new, if I do the (js/Object.create (.-prototype c)), the second call doesn't work even without optimizations

wilkerlucio22:07:16

but without running the workaround it works correctly for non advanced compilations