Fork me on GitHub
#re-frame
<
2023-11-07
>
Kimo18:11:43

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-himik18:11:00

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?

Kimo18:11:26

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.

Kimo19:11:50

Yeah, maybe a cursor is the way to go

p-himik19:11:59

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

valtteri21:11:22

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

valtteri21:11:27

Versus having them outside like now

p-himik21:11:30

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
mikerod23:11:00

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

p-himik08:11:36

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.

Kimo10:11:41

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.

Kimo10:11:59

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

p-himik10:11:44

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).

Kimo10:11:39

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.

Kimo10:11:49

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

p-himik10:11:13

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.

Kimo10:11:59

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

p-himik10:11:34

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.

Kimo10:11:56

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

Ben Lieberman18:11:37

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

1
Kimo18:11:55

You found the mind I left behind. Fixed.

1