Closed Run10Break1 closed 1 year ago
Hello,
Thanks for your feedback. That's right, types such as Map<K,V>
/List<T>
loose their specialization when crossing worker boundaries on Web platforms.
Using dynamic
is one way to go. I believe you could also use a bare List
. Using List<whatever>
is doomed because whatever
will not come through from the caller to the worker!
Also, have you tried using https://pub.dev/packages/squadron_builder? It should help you get rid of some boilerplate code as well as handle type considerations. The code generator tries its best to minimize side effects related to the lack of generics when communicating with a Web Worker. Note that I've never tested it with JsonConverter
. So do not hesitate to file an issue if you have problems squadron_builder
:-)
Closing this issue for now.
thank you, I will try squadron_builder
ps, I really appreciate you for making Squadron : )
recently, I stuck with a problem on the web. below is an error.
I figure out that the error comes from type casting on
.g.dart
, it changes from weak type (important, JS doesn't have a generic type) to strict type likeList<double>
.so, when you have an object containing other objects and want to encode the object on the Worker class and decode it on the Service class using code generated by
JsonSerializable
, change the type todynamic
.below is an example.
on the Web, there isn't a type like
List<double>
, onlyList
; so change like this.I know that README also says you should take care when using
JsonSerializable
, but I want to show another case.