jacobtipp / bloc-state Goto Github PK
View Code? Open in Web Editor NEWModern FlutterBloc ecosystem for TypeScript/React
Home Page: https://jacobtipp.github.io/bloc-state/
License: MIT License
Modern FlutterBloc ecosystem for TypeScript/React
Home Page: https://jacobtipp.github.io/bloc-state/
License: MIT License
I just wanted the bring up this feature request that doesn't exist in the original bloc ecosystem and listen to your perspective on it.
As things are, it's not possible to apply transformers on the stream that includes all events for a given bloc without using ad-hoc, non-declarative solutions that are hard to read on felangel/bloc. Considering all event handlers mutate the same state which belongs to a given bloc instance, this shortcoming eliminates one of the primary use cases of sequential event handling, concurrency, and using event driven architectures in the first place: write blocks.
I.e: If one event increases the stock levels, and the other consumes the stock, we are unable to ensure the second event is processed after the first one by leveraging the expressed bloc API. The suggested workaround to this problem is doing something similar to this:
class ExampleBloc extends Bloc<ExampleEvent, ExampleState> {
constructor() {
super(new ExampleInitial());
on<ExamepleEvent>(_onEvent, transformer: sequential());
}
async _onEvent(event: ExampleEvent, emit: Emitter<ExampleState>) {
if (event is ExamepleEventOne) { return await _onExamepleEventOneevent, emit);}
else if (event is ExamepleEventTwo) { return await _onExamepleEventTwo(event, emit);}
else if (event is ExamepleEventThree) { return await _onExamepleEventThree(event, emit);}
}
....
}
While this is usable, it's in my opinion clunky and needs commentary on why the code was organised this way to be readable. I don't have any suggested APIs for this use case but still wanted to bring it to your attention.
Best
First of all, let me share my thanks for attempting to undertake a huge project like this. We are in a situation where we need to port a huge flutter application that makes very extensive use of most of the unported packages and newer features of the bloc ecosystem to js and react, and bloc-state has been a life saver.
One question (as the first one of potential many others), I would like to know if anything similar to the BlocBuilder pattern within react-bloc package is available or in the works. It seems like while listening to a bloc to handle side-effects are possible, there is no component that enables rebuilding according to changing state. Is this by design?
Best
Description
react-bloc
is currently not compatible with react fast refresh
Steps To Reproduce
BlocProvider
to your react appBloc
you are providingExpected Behavior
Whenever code changes for a Bloc
, fast refresh should remount a BlocProvider
and recreate a new Bloc
instance that has the new code changes.
Currently, any code changes made to a Bloc
are not reflected with fast refresh.
Description
Add a view agnostic devtools implementation based around a BlocObserver
Desired Solution
A clear and concise description of what you want to happen.
BlocObserver
. An app should be able to conditionally wrap their own BlocObserver in a mixin without having to extend a devtools class.Alternatives Considered
None
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.