New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Use Annotation connect to localstate #66
Comments
Hey there -- thanks for writing in! Hrm, I'm honestly not sure I could properly support this. For me, two questions come to mind: Where does "hello" come from, and what action would be dispatched when the value is set so that you could handle the change in your reducer? If you're more interested in Getter / Setter type of Architectures, you might want to consider something like class MyModel extends Model {
String _hello = 'Hi there';
String get hello => _hello;
void set hello(String newValue) {
hello = newValue;
notifyListeners();
}
} Then in your Widgets, you could access the value like so, and this Widget be automatically rebuilt whenever the Model changes: ScopedModelDescendant<CounterModel>(
builder: (context, child, model) {
return FlatButton(
child: Text(model.hello),
onPressed: () {
model.hello = 'Yo Yo'
}
);
}
); |
ya you are right. class MyWidget extends StatelessWidget {
@store('hello', HelloAction) // <----
String hello;
@override
Widget build(BuildContext context) {
return Text(hello);
}
} if does not have action, it's just get from store, and with action, it will dispatch |
Hey there -- overall, I can see why you'd like to use this, but I don't think there'd be an easy way to support this. For example, where does the While I can see the usefulness of this feature, I think it might be better to try experimenting with this in a separate library. The only way I could see making this work is through code generation, and I'd like to keep that out of this lib for now. |
Dear author, i think this feature will make more perfect.
example:
this will get automatically get
hello
state from store and autodispatch
whenhello
variable are set.i think this is hard part, but may be it possible.
ps: sorry about my English 👯♂️
The text was updated successfully, but these errors were encountered: