Skip to content
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): support wasm #4230

Open
LukasMirbt opened this issue Aug 16, 2024 · 7 comments
Open

feat(hydrated_bloc): support wasm #4230

LukasMirbt opened this issue Aug 16, 2024 · 7 comments
Labels
enhancement New feature or request pkg:hydrated_bloc This issue is related to the hydrated_bloc package

Comments

@LukasMirbt
Copy link
Contributor

Description

The default HydratedStorage currently does not support WebAssembly compilation.

Reproduction steps:

  1. Create an empty Flutter application

  2. Add hydrated_bloc: ^9.1.5 to pubspec.yaml

  3. Replace main.dart with:

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  HydratedBloc.storage = await HydratedStorage.build(
    storageDirectory: HydratedStorage.webStorageDirectory
  );
  runApp(App());
}
  1. Run flutter run -d chrome --wasm --debug

Desired Solution

Support WebAssembly compilation with the default HydratedStorage.

Alternatives Considered

  • Using a custom HydratedStorage

Additional Context

Relevant GitHub conversation about wasm support in the Hive repo: isar/hive#1291

@felangel felangel added enhancement New feature or request pkg:hydrated_bloc This issue is related to the hydrated_bloc package labels Aug 21, 2024
@alexandrim0
Copy link

May be it is much easier to use hive_ce (drop in replacement which already supports wasm)?
But also it needs cut out using of dart:io.
I had an experiment and it works!

@alexandrim0
Copy link

@felangel would you move HydratedStorage class to new package to make this one independent of hive?

@felangel
Copy link
Owner

@felangel would you move HydratedStorage class to new package to make this one independent of hive?

What would be the benefit of a separate package? You can already swap out the storage.

@alexandrim0
Copy link

File hydrated_storage.dart contains both classes Storage and HydratedStorage, so it imports hive and dart:io.
That is why it wont works in wasm runtime, as wrote topic starter.

@quoc-huynh-cosee
Copy link

@felangel One benefit would be that if people don't use Hive as HydratedStorage, the license won't be listed. Currently even if a user opts not to use Hive, the license is still displayed using showLicensePage().

@felangel
Copy link
Owner

felangel commented Oct 4, 2024

We'd still need to ship a default HydratedStorage implementation if we decouple the package from hive. Are you all suggesting that we implement a custom key/value storage instead of using hive as the default?

@alexandrim0
Copy link

hive_ce could be as default storage to resolve this issue, except dependency on dart:io.
I can not see if it is simple for you to drop it or not.

But hydrated_bloc is a core package and should not dependent on any other specific packages, IMHO.
I still vote for separate packages for any specific storage.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg:hydrated_bloc This issue is related to the hydrated_bloc package
Projects
None yet
Development

No branches or pull requests

4 participants