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
2021-04-09T06:32:16.143300Z

It's a good practice that helps to find issues easier with only one big downside: the need to name things. But it is really helpful sometimes.

andre 2021-04-09T08:27:14.144300Z

hey ! new version of re-frisk is here https://github.com/flexsurfer/re-frisk [re-frisk-remote "1.4.0"] or [re-frisk "1.4.0"]

3❤️2🚀4🎉
andre 2021-04-09T08:27:59.145300Z

in this release • re-frame handlers statistics and usage statistics • show effects for events • list of mounted views with subscriptions (help with tree needed) • force update trace (really useful metric) (works only in re-frisk-remote, if you are interested in re-frisk implementation you are welcome 🙂 • improved subs graph • copy data to the clipboard

andre 2021-04-09T08:30:05.145600Z

Share you stat here 😉

andre 2021-04-09T08:30:18.146Z

stats for my re-frame project by re-frisk db: 76 | fx: 200 | cofx: 4 | event: 742 | sub: 404 (91)

andre 2021-04-09T08:34:23.148200Z

why render and force update is not in the re-frisk? because we need to patch reagent, but re-frisk UI also uses reagent, in that case traces will be flooded with re-frisk UI , this is solved in re-frame-10x, but i'm not sure this solution will work with shadow , i need to find more general solution

p-himik 2021-04-09T08:35:00.148400Z

I use re-frame-10x with shadow-cljs, works just fine.

andre 2021-04-09T08:35:10.148800Z

but try re-frisk-remote, probably you'll like it :)

andre 2021-04-09T08:37:37.149Z

hm ok

andre 2021-04-09T08:37:48.149200Z

i need to take a look once more

andre 2021-04-09T08:37:49.149400Z

[day8.re-frame-10x.inlined-deps.reagent.v1v0v0.reagent.core :as r]

andre 2021-04-09T08:37:56.149600Z

i thought this one works only with lein

p-himik 2021-04-09T08:38:41.149800Z

Why would it? IIRC re-frame-10x just ships the full Reagent code with its own codebase, and replaces the namespaces.

andre 2021-04-09T08:38:46.150Z

:mranderson {:mranderson {:project-prefix "day8.re-frame-10x.inlined-deps"}

andre 2021-04-09T08:40:01.150200Z

so its lein plugin

andre 2021-04-09T08:40:12.150400Z

:plugins [thomasa/mranderson "0.5.3"]

p-himik 2021-04-09T08:40:14.150600Z

> MrAnderson is a dependency inlining and shadowing tool Yep. But you can do all that yourself.

andre 2021-04-09T08:40:48.150800Z

thats true 🙂

andre 2021-04-09T08:41:14.151Z

ok i'll give it a try 😉

andre 2021-04-09T08:41:17.151200Z

thanks

1👍
andre 2021-04-09T09:34:59.152Z

https://www.youtube.com/watch?v=As--Ps43vT0

5👍
Umur Gedik 2021-04-09T11:36:50.153500Z

I think it is not difficult considering event handlers and subs needs to be defined in reframe anyway

2021-04-09T19:50:44.154100Z

What am I doing stupid here?

(defn point-canvas []
  [:div.content
   [:canvas#point-canvas.canvas
    {:on-mouse-down (fn [e] (rf/dispatch [:point-click {:x e.nativeEvent.offsetX :y e.nativeEvent.offsetY}]))}]])
I'm just trying to get the location of the mouse click in the canvas into a points array in app-db. The first time I click I get an empty points vector, the second time i click i get the first point location added. It's always 1 click behind.

p-himik 2021-04-09T19:53:12.154400Z

Not nearly enough information. > I get an empty points vector What do you mean by "get"? Where's that vector? What does :point-click handler do?

2021-04-09T19:53:28.154600Z

(rf/reg-event-db
 :point-click
 (fn [db [_ xy]]
   (update-in db [:points] conj xy)))

2021-04-09T19:53:42.154800Z

I'm watching app-db in re-frame-10x

2021-04-09T19:54:12.155Z

the first click I see app-db :points is [], then the second click I get the the location of the first click into :points

p-himik 2021-04-09T19:55:43.155200Z

LGTM. If you create a repo with an MRE, I can take a look. BTW it's better to use proper JS interop instead of e.nativeEvent.offsetX. E.g. (.. e -nativeEvent -offsetX). And replace (fn [e] ...) with (fn [^js e] ...) to avoid problems during advanced compilation. But it's not related to the behavior that you see.

1👍
2021-04-09T19:58:10.155600Z

oh! I was trying to do js interop and get compiler errors, but i was stupidly using just (.) and not (..)

p-himik 2021-04-09T19:58:14.155800Z

A gist it not a proper project.

2021-04-09T20:04:39.156Z

thanks, here's my project

2021-04-09T20:05:01.156500Z

there's nothing much in there, just draws a canvas and i want to get the points where they click. Cant see what I'm doing wrong.

2021-04-09T20:06:03.156700Z

is it good practice to type hint all js objects as ^js ?

p-himik 2021-04-09T20:07:08.156900Z

One small thing in advance - I'm not sure what .lsp dir there does, but you probably don't want to have it in a Git repo, given that it contains an SQLite DB.

p-himik 2021-04-09T20:07:42.157100Z

^js will let the compiler know that the related symbols in JS interop should not be mangled. Otherwise, it might rename them and the code will stop working in a release build.

2021-04-09T20:07:48.157300Z

hmmm. not sure what it is, wonder if calva puts that in there, maybe something to do with the calvas language server stuff

p-himik 2021-04-09T20:08:27.157500Z

Probably.

p-himik 2021-04-09T20:11:42.157700Z

Seems like you're hitting this: https://github.com/day8/re-frame-10x/issues/268

p-himik 2021-04-09T20:11:53.158Z

The data is there, it's just that re-frame-10x doesn't display it correctly.

p-himik 2021-04-09T20:12:20.158200Z

Also, look at the browser's JS console when you're developing - you have <buttton> there, which is an invalid tag.

2021-04-09T20:14:07.158400Z

how do i debug to actually see the data, like can i view it via the console?

2021-04-09T20:14:18.158600Z

what i mean is, can i view the app-db from the js/console?

p-himik 2021-04-09T20:14:26.158800Z

Sure, just log it.

p-himik 2021-04-09T20:14:35.159Z

(js/console.log db) right in your event handler.

2021-04-09T20:14:43.159200Z

great!

2021-04-09T20:14:56.159400Z

thanks for your help! Really appreciate it

p-himik 2021-04-09T20:15:15.159600Z

And when you add a sub that uses app-db, that issue with re-frame-10x should simply go away. Sure, np.

2021-04-09T20:15:57.159800Z

I've only really started looking at cljs in the last couple of weeks, so it's all still a bit new to me!

p-himik 2021-04-09T20:23:02.160Z

Some unsolicited meta-advice. If you eventually want to spend a lot of time in CLJS, try to build your knowledge from the bottom-up, not vice versa. Especially when you encounter issues. Otherwise, you may have a hard time resolving them. Of course, it's not because of CLJS - it's relevant to any technology stack. The higher the stack, the harder it will be to solve issues with it. Re-frame is relatively high up on the stack (JS -> CLJS -> (React ->) Reagent -> re-frame), so much harder to learn the basics at the bottom from so high up, especially if your tower is wobbly. And, of course, don't ignore the documentation. :) Re-frame has great documentation, shadow-cljs - just as well. In particular, that ^js thing is described here: https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs

1👍
p-himik 2021-04-09T20:26:12.160200Z

Just to add to the above - it's not to discourage you from posting questions - those are fine. :)

2021-04-09T20:26:58.160400Z

Yeah, I've found it honestly quite overwhelming coming into front-end stuff. I've been programming professionally for years but normally I'm doing either back end or systems stuff. Front-end is hard to see where to start.

2021-04-09T20:27:22.160600Z

When I step back and look at it, it seems a massive mountain of complexity that I need to learn.

2021-04-09T20:28:00.160800Z

I've done some JS at work, but not a great deal.

p-himik 2021-04-09T20:29:07.161Z

Frontend is a hard mess, yeah. CLJS makes it much better (IMO), but alas - it can't hide all issues of the platform. But you'll get there, no worries.