is there an explainer on what ui/dynamic does?
real question: what does ui/dynamic do? also wondering if there's an explainer I'm missing
ah ok, it seems to automatically listen to any atoms that are derefed in the bindings list
I wonder how it works...
ah it only seems to work when changing the atom in an event, like an on-click
so it's not watching the atoms
oh nm, it just wasn't re-rendering because it wasn't focused
Thing is it doesnโt actively listening
Buf if re-render happens it compares declared dependencies and if they changed rebuilds component tree inside
Itโs actually a temporary solution until we get some sort of state management
ahhh it reruns the inputs-fn on each event ๐๐ป
do you have a design in mind for state management?
Not yet
how does re-rendering components work?
Hope you don't mind me chiming in. I think it's worthwhile looking at https://github.com/thheller/shadow-grove as inspiration for state management.
i would not do that tbf for a generalized UI library. the whole "single atom with a normalized app db" state management doesn't make sense if you're trying to create reusable components that maintain their own state
things like shadow-grove's approach, re-frame, fulcro etc. make sense as higher level application frameworks
I agree with @lilactown
I hope for Humble UI to have universal layer that can be bridged with any state management
> how does re-rendering components work? When you call -draw. Itโs scheduled when -event returns non-nil, or you can schedule it manually by calling window/request-frame. The problem with dynamic as it is right now is that it will update when rendered but wonโt schedule re-render itself
This is very ad-hoc right now, so donโt give it much thought
I see, so -draw will locally redraw the component instance when called. it looks like most components also call -draw on their children when it's called, too.
does window/request-frame call -draw on the root component instance, which is what you mean by scheduling it manually? can I get a reference to a specific component and call -draw on it myself, to localize the re-render?
right now only from top level
it seems hard to render individual component instances because i need to call the -draw method not only with the component and context, but also a rect and canvas, which i'm not sure how to get a reference to
i know this isn't baked, i'm just poking around ๐ curious if i can try some experiments