re-frame

Kimo 2023-11-07T18:20:43.098839Z

I think we might start putting a :re-frame/system key into app-db. For now, it would store a map of registered flows. In the future, we might store other things like event handlers and the subscription cache. Any pitfalls we should look out for? Would this disrupt anyone's design/workflow?

๐Ÿ˜ฎ 1
p-himik 2023-11-07T18:24:00.408379Z

It would definitely trip up the people that rely on their app-db storing only the data that they themselves have put there. :) Not sure what the best solution is. Perhaps app-db can actually be a cursor and a ratom like full-app-db can contain it along with all the re-frame stuff?

Kimo 2023-11-07T18:53:26.245979Z

We would definitely list it as a breaking change. I think https://github.com/matthiasn/talk-transcripts/blob/master/Hickey_Rich/MaybeNot.md?plain=1#L1211 it should be okay. Practically, we're hoping it's okay to store it all under a single key. Then it's easy if you need to dissoc it.

Kimo 2023-11-07T19:01:50.220349Z

Yeah, maybe a cursor is the way to go

p-himik 2023-11-07T19:58:59.095989Z

It might have performance implications though. But probably nothing serious.

valtteri 2023-11-07T21:01:22.970679Z

Iโ€™d be curious to hear what benefits putting these into app-db would bring

valtteri 2023-11-07T21:02:27.047589Z

Versus having them outside like now

p-himik 2023-11-07T21:06:30.103299Z

See the pinned discussion that got started on November the 1st. tl;dr: the configuration of flows is intentionally dynamic, hence it's a part of your app's state.

๐Ÿ‘ 1
2023-11-07T23:57:00.841879Z

Hmm. The async-flow lib I believe puts stuff in the app-db too? I canโ€™t remember

Kimo 2023-11-12T10:19:41.694759Z

Testing this out, a problem already appeared. Many apps have an ::init event which resets the whole db. But if we store flows in app-db, that means the ::init event dissociates all the flows. The user would have to know and understand :re-frame/system to avoid this. Or we'd have to add some other implicit behavior to fix it. If app-db becomes a cursor into full-app-db, what benefit does that give us? We might as well just have two atoms, app-db and system. You have to call a second name either way, and full vs. not-full is a poor distinction. Basing re-frame's core state on a cursor sounds like asking for papercuts.

Kimo 2023-11-12T10:21:59.518599Z

As for trace and reproducibility, maybe tools like 10x can just start tracking system the same way they do app-db. Not sure.

p-himik 2023-11-12T10:22:44.484169Z

Mm, perhaps, yeah. And people that are interested in observing/storing the full system somehow will still be able to do it if system is a part of the public API (or if there's some function like get-full-state that returns a map of :system and :app-db).

Kimo 2023-11-12T10:25:39.368659Z

There is something conceptually nice about a single atom, though... Maybe it would suffice to change the :db effect, so it updates a subtree rather than the whole atom.

Kimo 2023-11-12T10:29:49.974239Z

Anyway this is starting to look big enough to be its own issue, and not a requirement for releasing flows.

p-himik 2023-11-12T10:32:13.347869Z

I agree that a single atom is conceptually nice. But after your messages above, I can't come up with a justification that would make it worth it. It might be worth it if re-frame was a backend framework since updating two atoms that store related data is a big "don't". But it's not the case in CLJS, especially given that only one of those is a ratom and the other would be a plain atom, I assume.

Kimo 2023-11-12T10:32:59.548869Z

Actually flows do need to be in an r/atom so you can subscribe to them.

p-himik 2023-11-12T10:34:34.579489Z

Oh... Hmm. I could be wrong but IIRC, if a component depends on two ratoms and you update those together, it will (or can?) result in two re-renders of the component back-to-back.

Kimo 2023-11-12T10:38:56.973009Z

Yeah I can see that behavior right now.. a live flow causes one render, but registering/clearing a flow causes two.

p-himik 2023-11-08T08:06:36.165069Z

Only if the user explicitly provides :db-path. But actually, perhaps it's not that big of a deal, to store stuff in app-db. A user still has to do something for that to happen. Either use the new flows directly or update some library that starts using flows in the newer version. It won't happen with updating just re-frame itself.

liebs 2023-11-07T18:36:37.193659Z

Am I losing my mind or did the search bar that used to be on the re-frame docs get removed?

โœ… 1
Kimo 2023-11-07T18:44:55.964549Z

You found the mind I left behind. Fixed.

๐Ÿ™Œ๐Ÿป 1
liebs 2023-11-07T18:45:15.250529Z

Thanks both!