re-frame

https://github.com/Day8/re-frame/blob/master/docs/README.md https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
dima 2021-03-15T14:06:56.216500Z

Hello πŸ‘‹ We’re using inject-sub-cofx helper from https://github.com/den1k/re-frame-utils/blob/master/src/vimsical/re_frame/cofx/inject.cljc which is also mentioned in the https://cljdoc.org/d/re-frame/re-frame/1.0.0-rc6/doc/faqs/how-can-i-use-a-subscription-in-an-event-handler#solutions. We think there is an issue exist: If you deref reagent atom outside of reagent rendering context, dependent subscription are not updated inside a watching list of parent subscription. So when you dispose! it, dependent subs are not getting disposed. Instead of using deref, should https://github.com/reagent-project/reagent/blob/4f40516b0b1e90aac7b35800b34c769f48986ac6/src/reagent/ratom.cljs#L426 be used which properly updates ratom watching list. I’ve put up example code demonstrating the issue https://gist.github.com/dmitryn/eff1ac30948913490f6feff396f26b9f

dima 2021-03-16T14:23:45.000400Z

Also, created an issue in re-frame-utils repo https://github.com/den1k/re-frame-utils/issues/9

p-himik 2021-03-15T14:10:09.216700Z

Can you add relevant usages of dispose! to your gist, so it's more clear?

dima 2021-03-15T14:14:12.216900Z

Yes, updated the comment there

p-himik 2021-03-15T14:24:45.217100Z

No clue what's going on there. Frankly, no clue what exactly run is doing as well. That's an incredibly densely packed part of Reagent with barely any documentation. Also, no clue why the second (.-watching sub) returns two items instead of one.

p-himik 2021-03-15T14:26:26.217300Z

But it seems like you could get rid of all the re-frame specific stuff and ask a similar question in #reagent.

dima 2021-03-15T14:37:12.217500Z

Yes, it’s more a reagent.ratom question, rather than re-fame. The reason i asked because inject-sub-cofx is a re-frame utility and it also mentioned in re-frame docs so people probably use it

caumond 2021-03-15T21:39:29.222Z

Hi everybody, I am trying to internationalize my re-frame app. First question. I try tempura, is it what you advice to use with re-frame? Then I was originally trying to link it to a subscribe. (def tr (partial tempura/tr opts [(rf/subscribe [::subs/language])])). But it seems not working. I'm not sure to understand why. my language is a keyword, like :en and the usage (tr [:example]). The following error occurs

Uncaught Error: Doesn't support name: [object Object]
    at Object.cljs$core$name [as name] (core.cljs:9524)
    at Function.eval (impl.cljc:314)
    at Function.eval [as cljs$core$IFn$_invoke$arity$3] (core.cljs:3918)
    at Function.eval [as cljs$core$IFn$_invoke$arity$2] (core.cljs:3913)
    at Function.eval [as cljs$core$IFn$_invoke$arity$2] (core.cljs:3948)
    at G__48897__delegate (encore.cljs:1655)
    at G__48897 (encore.cljs:1636)
    at eval (impl.cljc:325)
    at eval (core.cljs:5648)
    at eval (core.cljs:5648)

caumond 2021-03-15T21:41:09.222100Z

I'm not sure to understand what is happening there.

p-himik 2021-03-15T21:41:30.222300Z

I'm using tempura as well, I find it quite nice. In your code, you're feeding tr the ratom returned by subscribe. You want to deref that ratom first.

p-himik 2021-03-15T21:43:12.222500Z

I use tr within a :tr sub. And then I have my own version of tr that's basically #(deref (subscribe [:tr %])). Of course, that tr must be used only in views and only during rendering.

caumond 2021-03-15T21:47:26.222700Z

ouch, I feel a little bit embarrassed, so obvious.... I definitely need to improve my use of cljs repl for a better debugging. Thx it works

πŸ‘ 1
caumond 2021-03-15T21:51:42.223Z

@p-himik, is it supposed to happen in clj side or cljs side?

caumond 2021-03-15T21:52:38.223200Z

I expect cljs side for my subscribe, but I see functionnalities in tempura using resources on disk

caumond 2021-03-15T21:53:26.223400Z

the :__load_resource functionnality

p-himik 2021-03-15T21:58:23.223600Z

CLJS, of course. But you can use tempura on CLJ side - e.g. for SSR or for some data coming from the server. I don't like :__load-resource for two reasons: - It's pretty much undocumented - Inlining l10n resources makes it harder to implement language switching in runtime without inflating the bundle size. I prefer to serve the l10n data from the server - only the language that's currently selected.

p-himik 2021-03-15T21:59:18.223800Z

Ah, also judging by the code, you will see the "Runtime resource loading not possible for cljs dictionaries. See tempura/load-resource-at-compile-time` as an alternative."` error if you use it with CLJS.

πŸ‘ 1