-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
feat(bloc)!: BlocOverrides API #2932
Conversation
Codecov Report
@@ Coverage Diff @@
## feat/v8.0.0 #2932 +/- ##
=============================================
Coverage 100.00% 100.00%
=============================================
Files 25 25
Lines 671 691 +20
=============================================
+ Hits 671 691 +20
Continue to review full report at Codecov.
|
feb6559
to
0fece16
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
6d21a51
to
b2dea9c
Compare
e904b3c
to
54140b8
Compare
54140b8
to
d0220d3
Compare
453ebe3
to
eef7b60
Compare
Status
READY
Breaking Changes
YES
Description
The current API used to override the default
BlocObserver
andEventTransformer
is:This approach relies on a global singleton for both the
BlocObserver
andEventTransformer
. As a result, it's not possible to:BlocObserver
orEventTransformer
implementations scoped to different parts of the applicationBlocObserver
orEventTransformer
overrides be scoped to a packagepackage:bloc
registers its ownBlocObserver
, any consumer of the package will either have to overwrite the package'sBlocObserver
or report to the package'sBlocObserver
.It's also more difficult to test because of the shared, global state across tests.
This pull request introduces a
BlocOverrides
class which allows developers to overrideBlocObserver
and/orEventTransformer
for a specificZone
rather than relying on a global, mutable singleton.Bloc instances will use the
BlocObserver
and/orEventTransformer
for the currentZone
viaBlocOverrides.current
. If there are noBlocOverrides
for the zone, they will use the existing internal defaults (baseBlocObserver
and concurrentEventTransformer
-- no change in terms of behavior/functionality).As previously mentioned, this would allow each zone to function independently with its own
BlocOverrides
andBlocOverrides
are immutable meaning theBlocOverrides
specified when the zone is created cannot be modified.This pull request removes the static, mutable
Bloc.observer
andBloc.transformer
APIs which is a breaking change.BlocObserver
andEventTransformer
overrides will need to be specified viaBlocOverrides.runZoned
instead as described above.Type of Change