nank1ro / solidart

Signals in Dart and Flutter, inspired by SolidJS
https://docs.page/nank1ro/solidart
MIT License
155 stars 5 forks source link

is `Solid()` here have the same concept like useContext in ReactJS or createContext in SolidJS ? #81

Closed tsanyqudsi closed 9 months ago

tsanyqudsi commented 9 months ago

Hey, I've been wandering all these years searching for nice state management in Flutter.

As for my background, I use jotai in react and used nanostores in SolidJS once ( not really using solid since many of my works asking for "future maintainability with inhouse dev" (and they don't wanna know how good solidjs is).

So I've been wondering, is there a feature where you can do createStore ? Because in your readme you stated Do not have a single global state, but multiple states only in the most appropriate places. So I assume it's like Context ? But I'm not really sure.

nank1ro commented 9 months ago

Hello, createContext and createStore are two completely different things, I didn't quite understand if the question is referring to one or the other. I will answer both:

createContext

The Solid widget has the same purpose as createContext to provide children with access to values without passing the parameters down in each child. In addition with Solid the descendants can update the value of the provided signals.

createStore

There is no store in solidart, but not because it is not feasible, but because it is very resource intensive. Each property would become a signal. In Flutter this is not even necessary. If you need to create a derived signal you have to use Computed and if you have to manage collections of values then you have to use ListSignal, SetSignal and MapSignal.

tsanyqudsi commented 9 months ago

Thank you for the explanation. Yes, it's a completely different thing, that is why I asked the question.

Will close the issue for the satisfying explanation.