-
-
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(hydrated_bloc)!: HydratedBlocOverrides API #2947
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
felangel
added
enhancement
New feature or request
breaking change
Enhancement candidate would introduce a breaking change
pkg:hydrated_bloc
This issue is related to the hydrated_bloc package
labels
Nov 15, 2021
felangel
force-pushed
the
feat/hydrated-bloc-overrides
branch
from
November 15, 2021 01:51
41aadc8
to
b99738c
Compare
felangel
force-pushed
the
feat/hydrated-bloc-overrides
branch
from
November 15, 2021 01:58
b99738c
to
377b094
Compare
felangel
force-pushed
the
feat/hydrated-bloc-overrides
branch
from
November 15, 2021 02:02
377b094
to
adb2af0
Compare
felangel
added a commit
that referenced
this pull request
Nov 17, 2021
felangel
added a commit
that referenced
this pull request
Nov 18, 2021
Could you do a more verbose example
|
Hi there ! May you explain what you mean a little bit more here? |
Hi you can check out the example. void main() async {
FlutterServicesBinding.ensureInitialized();
final storage = await HydratedStorage.build(
storageDirectory: kIsWeb
? HydratedStorage.webStorageDirectory
: await getTemporaryDirectory(),
);
HydratedBlocOverrides.runZoned(
() => runApp(App()),
storage: storage,
);
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
breaking change
Enhancement candidate would introduce a breaking change
enhancement
New feature or request
pkg:hydrated_bloc
This issue is related to the hydrated_bloc package
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Status
READY
Breaking Changes
YES
Description
The current API used to override the default
Storage
is:This approach relies on a global singleton for the
Storage
. As a result, it's not possible to:Storage
implementations scoped to different parts of the applicationStorage
overrides be scoped to a packagepackage:hydrated_bloc
registers its ownStorage
, any consumer of the package will either have to overwrite the package'sStorage
or use the existingStorage
implementation.It's also more difficult to test because of the shared, global state across tests.
This pull request introduces a
HydratedBlocOverrides
class which allows developers to overrideStorage
for a specificZone
rather than relying on a global, mutable singleton.HydratedBloc instances will use the
Storage
for the currentZone
viaHydratedBlocOverrides.current
.As previously mentioned, this would allow each zone to function independently with its own
HydratedBlocOverrides
andHydratedBlocOverrides
are immutable meaning theHydratedBlocOverrides
specified when the zone is created cannot be modified.This pull request removes the static, mutable
HydratedBloc.storage
APIs which is a breaking change.Storage
overrides will need to be specified viaHydratedBlocOverrides.runZoned
instead as described above.Type of Change