Fork me on GitHub
#om
<
2016-10-14
>
dzannotti09:10:40

how do i force a refetch in om/next ?

rackdon10:10:31

What is the difference between

(def user-section
  [:div {:class "header-column header-column-valign-top"}
    [:nav {:class "header-nav-top"}
      [:ul {:class "nav nav-pills"}
        [:li 
            [:a.clickable {:class "rowLanguage"  :on-click (fn[_] (set-locale :en-GB))} (i18n/translate :english)]
            [:span "-"]
            [:a.clickable {:class "rowLanguage" :on-click (fn[_] (set-locale :es-ES))} (i18n/translate :spanish)]]
        [:li "goToAccount"]
        [:li "login"]
        ]]])

(def main-section
  [:div {:class "header-row"}
    [:div {:class "header-column"}
      user-section]])
and
(def main-section
  [:div {:class "header-row"}
    [:div {:class "header-column"}
      [:div {:class "header-column header-column-valign-top"}
    [:nav {:class "header-nav-top"}
      [:ul {:class "nav nav-pills"}
        [:li 
            [:a.clickable {:class "rowLanguage"  :on-click (fn[_] (set-locale :en-GB))} (i18n/translate :english)]
            [:span "-"]
            [:a.clickable {:class "rowLanguage" :on-click (fn[_] (set-locale :es-ES))} (i18n/translate :spanish)]]
        [:li "goToAccount"]
        [:li "login"]
        ]]]]])
In the second case when I click, the language is translated, but in the first not, and I can’t know why 😔

rackdon10:10:40

the only difference that I can see is that in the second case I separate the code in two methods…..

dzannotti12:10:39

@cjmurphy are you saying that i should trigger an dummy transaction to force a refresh (remote) from my component?

levitanong13:10:26

I’m using om.next with re-natal, and I’m getting a curious error when transacting inside an onPress handler in a ListView.

null is not an object (evaluating ‘new cljs.core.Keyword(null,”history”,”history”,-247395220).cljs$core$IFn$_invoke$arity$1(cfg).add`)
It’s obviously referring to https://github.com/omcljs/om/blob/e5d3e2e7d56185e07b9a9d7c46bf88c3f2cba247/src/main/om/next.cljc#L1554 Could something be overriding the .add method of whatever (:history cfg) returns? I’ll go out on a limb and tag @anmonteiro

anmonteiro13:10:33

there are some wrinkles in React Native

anmonteiro13:10:01

I would probably check if (om.next/get-reconciler this) has a value in the component you’re transacting from

anmonteiro13:10:14

if it’s nil it confirms my suspicions

levitanong13:10:53

Oh damn, that will probably be it. Having some trouble compiling, so I might have to check on this again tomorrow

levitanong13:10:11

Any suggestions on how to proceed if your suspicions are correct?

anmonteiro13:10:38

@levitanong the first attempt I would make would be to try out omify

anmonteiro13:10:03

it sets up the correct bindings for plain React components

anmonteiro13:10:35

so before using a ListView or w/e it’s called, you’d (omify! ListView) or something

levitanong13:10:44

@anmonteiro Interesting! looking forward to trying that out 😄 Thanks man!

anmonteiro13:10:00

no docs yet, but have a look at the tests or the devcards

dzannotti14:10:16

@anmonteiro any suggestions on how to trigger a refresh (with remotes) for a specific component?

anmonteiro14:10:46

@dzannotti hrm, you’ll probably have to roll your own, until this is a thing: https://github.com/omcljs/om/issues/485

petterik15:10:40

@levitanong Are you creating components outside render? om.next binds *reconciler* and other dynamic vars when it calls render. I've had issues where I pass functions to React Native components and they get called outside of render, which results in those components having nil returned from get-reconciler. I'm using a macro similar to this one to make sure I get the om.next vars bound: https://github.com/hugoduncan/navigator-repro/blob/master/src/navigator_repro/macros.clj Usage: https://github.com/hugoduncan/navigator-repro/blob/68bbd63588cc109897452ee6cadbf13bbc0bf1a9/src/navigator_repro/core.cljs#L147

anmonteiro16:10:13

@levitanong can you provide more context wrt #804?

anmonteiro16:10:21

doesn’t work where? client or server? which function?

anmonteiro16:10:27

maybe even a minimal repro

levitanong17:10:42

@anmonteiro Sorry about the terseness of #804. Doesn’t work on client, I haven’t tested it on server.

…
Object
(componentDidMount [this]
  (println (om/react-ref :foo)) ;; returns nil
  (println (om/react-ref “bar”))) ;; returns the component
(render [this]
  (dom/div nil
    (dom/div {:ref :foo})
    (dom/div {:ref “bar”})))

anmonteiro17:10:17

@levitanong what if you call it like this: (om/react-ref “:foo")

anmonteiro17:10:31

(just trying to narrow down the issue)

anmonteiro17:10:02

to be clear, have the :foo ref as a keyword, but look it up as a string with :

levitanong17:10:07

@anmonteiro Well that’s weird, I can’t reproduce it anymore.

levitanong17:10:02

Thing is, this has happened before. Will close the issue, will reopen and look for “:foo” when it happens again.

levitanong17:10:42

@petterik Thanks for the advice! I will take a look at that as well, when I figure out why my simulator isn’t connecting to figwheel anymore 😛

anmonteiro17:10:05

@levitanong FWIW I think Boot-React-Native gets more updates than re-natal https://github.com/mjmeintjes/boot-react-native

anmonteiro17:10:11

but I haven’t been following closely

levitanong17:10:15

@anmonteiro I’ve looked into this also, but the react-native version is still far behind 😞

anmonteiro17:10:35

gotcha, just wanted to make you aware of that project in case you weren't

anmonteiro17:10:41

seems like you got it covered though

levitanong17:10:07

Thanks 🙂 Though it seems I don’t got it covered at all. Ugh, leiningen.

levitanong17:10:02

Oy, vey! I figured it out. IP address issue.

levitanong17:10:40

@anmonteiro Just tested om/get-reconciler. Yep, it’s returning nil

levitanong18:10:31

@petterik Your suggestion worked with one modification! I had to remove the macro-ness of it, and use it as a plain function. When I was using it as a macro, react was complaining that it was expecting valid react components, when it was instead receiving cljs.core/let. This is unsettling though. Like, is the macroexpansion happening at the wrong place?

levitanong18:10:55

@petterik scratch that, my mistake! Forgot to make my util namespace .cljc. Sorry for the noise! Also, you have my thanks! Your advice was spot-on.

Joe R. Smith18:10:15

what’s the “right” way to force a (remote) query for a component?

Joe R. Smith18:10:10

I saw that, I’m not sure, really. I guess what I really want is to perform an arbitrary query and have the result get integrated

iwankaramazow19:10:45

@solussd I think you'll need to perform a mutation in that case

anmonteiro19:10:36

@solussd I think you’re looking for the same thing someone asked earlier today, probably still in the backlog. Anyway, the answer is you’ll have to roll your own thing until this becomes a thing: https://github.com/omcljs/om/issues/485

Joe R. Smith19:10:00

can I transact without a mutation (only reads wrapped with force)?

anmonteiro19:10:55

well that’s an interesting one. I’ve never tried it, but should be possible in theory, I think

anmonteiro19:10:31

@solussd if that turns out to work, maybe it even obviates the need for touch!

iwankaramazow19:10:33

That's the whole setup of Untangled isn't it?

anmonteiro19:10:21

having a brief look at the code suggests that it might indeed be possibile. Interesting

Joe R. Smith19:10:14

@anmonteiro, I actually don’t care about the component, specifically. I need to force re-reading some data in cases where sideloaded data fails for whatever reason. (I.e., perform optimistic update/mutate remote that kicks off an async change, track the fact that it was an optimistic update and, if after some amount of time I don’t get the new value sideloaded, e.g. via sse, I want to explicitly re-read from the remote)

Joe R. Smith19:10:21

cool, well, I can try it. 🙂

anmonteiro19:10:50

@solussd let me know how it goes!

ag20:10:37

hey guys.. I’m getting this No method in multimethod 'read' for dispatch value: :remote. Remember when it sends :remote key with the payload to the server. There was a way I remember somehow to remove it, no?

ag20:10:06

so it would send “flattened” ast to the remote if there’s only one remote

ag20:10:51

nevermind… send’s first param is a map of remotes

arohner21:10:24

Trying to wrap my head around Om Next. Is :send only used for remote queries, or is it also used for mutation?