redbrogdon / rebloc Goto Github PK
View Code? Open in Web Editor NEWA state management library for Flutter that combines aspects of Redux and BLoC.
License: BSD 3-Clause "New" or "Revised" License
A state management library for Flutter that combines aspects of Redux and BLoC.
License: BSD 3-Clause "New" or "Revised" License
Given the following code:
Default override fill in code:
@override
FutureOr<Action> middleware(DispatchFunction dispatcher, ExpandingCardState state, Action action) {
// TODO: implement middleware
return super.middleware(dispatcher, state, action);
}
or Modified to return action explicitly
class ConstraintBloc extends SimpleBloc<ExpandingCardState> {
@override
FutureOr<Action> middleware(DispatchFunction dispatcher, ExpandingCardState state, Action action) {
// TODO: implement middleware
return action;
}
}
Why do I get the following analysis error?
'ConstraintBloc.middleware' ('((Action) → void, ExpandingCardState, Action) → dynamic') isn't a valid override of 'SimpleBloc.middleware' ('((Action) → void,
rebloc-0.2.1/lib/src/widgets.dart:10:1: Error: 'Action' is imported from both 'package:flutter/src/widgets/actions.dart' and 'package:rebloc/src/engine.dart'
patch to fix this: iyatsouba@42b405a
I found the statelesswidget used in it all. Does this have any effect on performance?
a quick fix:
--- engine.dart
+++ engine.dart
@@ -104,8 +104,10 @@
reducerStream.listen((a) {
assert(a.state != null);
- states.add(a.state);
- _afterwareController.add(WareContext<S>(dispatcher, a.state, a.action));
+ if (a.action is! _CancelledAction) {
+ states.add(a.state);
+ _afterwareController.add(WareContext<S>(dispatcher, a.state, a.action));
+ }
});
// Without something listening, the afterware won't be executed.
I have a usecase in my app and I need to load the initial state by querying the SharedPreferences package.
How can I make the initial state of my app asynchronous?
Would you pleaser update RxDart to latest version (0.24.0)?
@RedBrogdon
Thanks for the great library rebloc. I am trying to figure out how I can use a SimpleBloc with a widget that has TextFields.
I have seen samples where the standard BLOC exposed streams and functions that access the sinks, and are wired to StreamBuilder that return the TextField.
If I used rebloc, would I have to maintain state and validate the TextField within the widget, and simply dispatch actions for something like the login passing the username/password?
I liked the separation and hidden logic within the standard BLOC, but not sure how to use a VIewModelSubscriber in place of a StreamBuilder while exposing Streams/Sinks from the SimpleBloc.
Hello @RedBrogdon
Thanks for the package, since I stumbled upon it, its been my number choice for state management.
This question has been asked before, so I took time out to repurpose one of my earlier projects from Redux to Rebloc.
You can have a look at TailorMade and maybe you can give a shout if it can serve as a pointer for others wanting to use this combination.
Jeremiah.
Hi,
In my bloc
class I listen to location event. How can I dispatch an action on each event?
class TrackingBloc extends SimpleBloc<AppState> {
...
bg.BackgroundGeolocation.onLocation((bg.Location location) {
dispatcher(DoSomethinWithLocation(location));
}
...
}
Thanks for the great library!
Could you help to update the dependencies to follow the latest release? Thanks!
Is it possible to use this app with AngularDart or VueDart?
If so, some examples would be awesome.
Since there is nowhere else to say this, Thank you @RedBrogdon.
This is super awesome!!
When I opened example, two errors occurred. Provide solutions for those in need.
First mistake, No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android.
Solution, go to the official website to download "Android NDK, Revision 16b", and then put the "mips64el-linux-android-4.9" in "Android\sdk\ndk-bundle".
https://developer.android.com/ndk/downloads/older_releases
Second mistake, Failed to execute aapt.
Solution, in "android/app/build.gradle", modify "compileSdkVersion" to 28.
Nice redesign of the redux ideas. I've been doing something similar (still WIP), but with blocs keeping their state as an accumulated state in a stream, using the stream's scan()
to call its reducer.
What seems to be missing in rebloc, but what I used frequently with react-redux in the past, is the ability to execute middleware functions after the reducer(s) have changed the state. For example, after changing the state you may want to perform some external actions, like logging, sending a network message about the finished action (MQTT in my case), etc. In react-redux, everything after next(action)
in the middleware function could do this.
Wondering whether you could think about how to add this functionality in some way to rebloc.
I think this plugin is so brilliant and make state management much easier!
Thank you so much.
However I would like to know how to update UI when Firestore
data changed or created in this plugin. For instance, when you put a new item in shopping cart, cart icon's number updates like flutter talk in IO. Since bloc attached to this plugin, I think I should put login in there but I'm not sure how to do it. Could you give an example?
Again thank you for great plugin.
First of all, thank you @RedBrogdon for create such a good library. I very appriciate it.
(Also a lot of good episodes on boring flutter that I love to watch)
But one thing I want to mention is the readme document on https://pub.dartlang.org/packages/rebloc#-readme-tab- have a typo
I saw that you've fixed it in your commit but it's not propogate to pub.dartlang.org yet.
Could you help correct it? (for a good impression of new comer)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.