Open csells opened 3 years ago
Thanks. I've just published a remake of the official Flutter app: Shopper using streams with Sprinkle. I'm working on a task management app with Firebase integration. It will be released soon, hopefully. ;)
shopper-sprinkle-example
is good thnx, still leaves a few questions however as the login form is not wired up. maybe because I am new to flutter so connecting the dots on how to use it for form data is unclear. Should I use a stream for local state as well?
In that case, why don’t we use streams everywhere? whether it’s an external interaction with a database / API, or an internal one with the local state,
I guess, coming from React (hooks~) this feels verbose for local state?
Crude example..
function LoginScreen({}) {
const [email, setEmail] = useState("")
...
<TextInput value={email} label="Your email" onChangeText={setEmail}></TextInput>
...
<Button onPress={() => { dispatch(actions.signin(email)) }>Continue</Button>
}
Start by creating a Manager. It's a class that manages one or many data stores. It also exposes actions as methods to change the state in these data stores.
Actually I guess it makes sense. So LoginManager
to handle the state and actions.
Ok, managed to make this work but having a form example (with validation!) would be useful, also found myself in a situation of needing to observe multiple values from manager for a single field, was unclear if that was possible.
Yes, I'd like to come up with a set of (convenient) practices on how to use streams for the local state too. The first step is there with Sprinkle and some extension methods wrapping the BehaviorSubject
from RxDart.
I have a login example done. I'll release it soon, hopefully. :)
@zaiste did you ever release the task managment and login examples ?
just use a known state management solution, eg provider or Riverpod (my favorite now) for example. This repo and many other half baked solutions just like it adds to the confusion for those begining the Flutter path.
I like that your counter app is simple; that's a good first step for any state management solution.
I'd like to see a more comprehensive example that includes auth and serialization and a more complicated data object/set of data objects. Perhaps a per-user TodoList that lives in Firebase? Something along these lines: https://fluttersamples.com/