Bloc: Web Support

Created on 17 Oct 2018  路  12Comments  路  Source: felangel/bloc

Very nice package!

I would like to know if this package will be compatible with Dart for Web, like AngularDart.

Thanks in advance.

enhancement

Most helpful comment

@bohrmeista I took a look and it looks like runtimeType is the problem in the release build.
If you replace your mapEventToState implementation with:

@override
  Stream<TestState> mapEventToState(TestState state, TestEvent event) async* {
    yield TestState.loading();
    if (event is UpdateEvent) {
      await _getTest();
      yield TestState.result(_response);
    }
    if (event is ClearEvent) {
      yield TestState.result('');
    }
  }

it will work.

Runtime type isn't something I'd use for program logic. It changes based on compiler options, and actually even using it can make optimizations for your app (in dart2js) much harder.

I would recommend adding your own type implementation to your events if you want to be able to use a switch statement.

All 12 comments

Thanks!

Yes, this is something that we are discussing and should be coming soon.

Thanks!

Yes, this is something that we are discussing and should be coming soon.

Thanks for the response. Good to know!

12 addressed this issue. The bloc package now has no flutter dependency. All Flutter widgets have been moved to flutter_bloc

Hello, I find your package very helpful when developing AngularDart and Flutter apps on the same codebase.

However I recently found that using webdev serve --releaseor webdev build (both producing release builds) makes the plugin unusable as in 'compiles fine, no runtime errors - but no functionality'.

For reference on what I tried check out these gists:

When running in development mode (without --releaseor with --no-release) it works fine though.
Just using rxDart in an AngularDart app works just fine on the contrary, so I really think the problem lies within this plugin.

For now, I'd propose reopening this issue or opening a new one if you'd like to make it more specific.

@bohrmeista thanks for bringing this to my attention. I will take a look at your gists and see if I am able to identify the root cause of this problem. In the meantime, it would be great if you could open a new bug issue and provide as much detail as possible. Thanks again for bringing this up! 馃憤

I'm just going to keep this issue closed since it sounds like more of a bug than an enhancement. It would be great if you can just open a bug for this and I will investigate :)

@katutz have you had a chance to test the package in AngularDart? Just wondering if you're running into the same issue or not.

@felangel I implemented a mock version of the app again to make sure the error is really there and also wrote a test for the BLoC stuff so you might want to use it to test after you've made changes.
https://github.com/bohrmeista/dart_experiments
See the README.md for info on running the test.

I will also create a new issue tomorrow.

@bohrmeista I took a look and it looks like runtimeType is the problem in the release build.
If you replace your mapEventToState implementation with:

@override
  Stream<TestState> mapEventToState(TestState state, TestEvent event) async* {
    yield TestState.loading();
    if (event is UpdateEvent) {
      await _getTest();
      yield TestState.result(_response);
    }
    if (event is ClearEvent) {
      yield TestState.result('');
    }
  }

it will work.

Runtime type isn't something I'd use for program logic. It changes based on compiler options, and actually even using it can make optimizations for your app (in dart2js) much harder.

I would recommend adding your own type implementation to your events if you want to be able to use a switch statement.

@felangel I tested this in my actual app and now it works just fine. Thanks a lot and sorry for causing you work with this. This actually helped me a lot and I learned something again so big 馃憤

@bohrmeista no problem! Glad I could help 馃憤

I'm just going to keep this issue closed since it sounds like more of a bug than an enhancement. It would be great if you can just open a bug for this and I will investigate :)

@katutz have you had a chance to test the package in AngularDart? Just wondering if you're running into the same issue or not.

I haven't tested in AngularDart yet. But I'm glad to see that the problem is solved. Very good work @felangel !

Thanks! I鈥檒l start working on adding examples/documentation on AngularDart usage in the next few days 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

1AlexFix1 picture 1AlexFix1  路  3Comments

shawnchan2014 picture shawnchan2014  路  3Comments

craiglabenz picture craiglabenz  路  3Comments

hivesey picture hivesey  路  3Comments

Reidond picture Reidond  路  3Comments