Hello team,
Thanks for fixing #145 so quickly. I can confirm the project builds now, but it still doesn't run in WebAssembly (raises UnimplementedError right at the subscription point).
I've had a look around, and I think there are a couple of places that are using the deprecated dart:html: one and two
I believe this is why WASM raises the error (or at least one reason). It would be great if they could be replaced with package:web. More information here and here.
Here's a minimal Flutter app that reproduces the issue (make sure to run with WASM: flutter run -d chrome --wasm):
import 'package:flutter/material.dart';
import 'package:pubnub/pubnub.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatefulWidget {
const MainApp({super.key});
@override
State<MainApp> createState() => _MainAppState();
}
class _MainAppState extends State<MainApp> {
late final PubNub pubnub;
late final Subscription subscription;
String latestMessage = 'No Message Yet';
@override
void initState() {
super.initState();
pubnub = PubNub(
defaultKeyset: Keyset(subscribeKey: 'sub-c-XXXXXXXX', userId: UserId('demo')),
);
subscription = pubnub.subscribe(channels: {'channel-test'});
subscription.messages.listen(
(e) {
// Handle incoming messages
print("MESSAGE RECEIVED: ${e.payload}");
setState(() {
latestMessage = e.payload.toString();
});
},
onError: (e) async {
print("ERROR: $e");
setState(() {
latestMessage = "ERROR: $e";
});
},
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(body: Center(child: Text(latestMessage))),
);
}
}
This migration guide might help: https://dart.dev/interop/js-interop/package-web
I appreciate your help in refactoring the deprecated code, and your work overall in maintaining Pubnub : )
Switching to WASM is showing significant performance gains.
Thank you.
Hello team,
Thanks for fixing #145 so quickly. I can confirm the project builds now, but it still doesn't run in WebAssembly (raises
UnimplementedErrorright at the subscription point).I've had a look around, and I think there are a couple of places that are using the deprecated
dart:html: one and twoI believe this is why WASM raises the error (or at least one reason). It would be great if they could be replaced with
package:web. More information here and here.Here's a minimal Flutter app that reproduces the issue (make sure to run with WASM:
flutter run -d chrome --wasm):This migration guide might help: https://dart.dev/interop/js-interop/package-web
I appreciate your help in refactoring the deprecated code, and your work overall in maintaining Pubnub : )
Switching to WASM is showing significant performance gains.
Thank you.