brutha icon indicating copy to clipboard operation
brutha copied to clipboard

Local state

Open SevereOverfl0w opened this issue 7 years ago • 5 comments

I can't see any way to handle local state in Brutha, am I just being dim? 😁

SevereOverfl0w avatar Mar 11 '17 21:03 SevereOverfl0w

Brutha components are effectively stateless. Rather than attaching state to components and treat them like objects, in Brutha components are generally just a way of caching for performance. State is handled separately, by either an atom or something more complex, like DataScript.

weavejester avatar Mar 11 '17 22:03 weavejester

My use-case was for handling direct DOM access & interacting with js libs (e.g. d3). I figured out I could do goog.object/set on this inside the component.

I generally agree that everything should be stateless, but holding onto state related to the DOM doesn't seem to fit. Do you still put that kind of state into your atom or similar?

SevereOverfl0w avatar Mar 19 '17 13:03 SevereOverfl0w

Sorry for the delayed response; it's been a busy few weeks for me. Could you explain a little more about what you're trying to do?

Brutha pushes all questions of handling state aside. It doesn't have an opinion on where you store state, just that Brutha itself doesn't handle it.

weavejester avatar Mar 24 '17 05:03 weavejester

I'm trying to use javascript libraries like D3. I'm quite happy that all domain state live in an atom or similar. But for things like a reference to the D3 mutable object that lives & dies by the lifecycle of my component.

In essence, for wrapping mutable javascript DOM stuff, I'm wondering where to put stuff.

SevereOverfl0w avatar Mar 26 '17 20:03 SevereOverfl0w

I think I get the gist of the problem, now. Let me give this some hammock time :)

(It might be a while before I get around to doing something about this, though, as my attention is currently on Duct and Integrant.)

weavejester avatar Mar 27 '17 10:03 weavejester