wallforfry / dart_mercure

Dart library for dunglas/mercure
BSD 2-Clause "Simplified" License
13 stars 4 forks source link

subscribeTopics not working #8

Open yurik94 opened 3 years ago

yurik94 commented 3 years ago

Hello, I'm trying to implement this lib. I have a fully working Mercure instance with Docker, I'm sure it's working because from plain JS it works fine.

Future<Mercure> initMercure() async {

mercureClient =
        Mercure(token: authMercure.jwt, hub_url: authMercure.hub_url);

    // Subscribes to topics
    mercureClient.subscribeTopics(
        topics: authMercure.topics,
        onData: (Event event) {
          print(event.data);
        },
        onError: (Object o) {
          print('onError');
        },
        onDone: () {
          print('onDone');
        });
        return mercureClient;
}

none of the callbacks are called, from chrome/web I see the stream opened successfully with 200 code.

called from:

class _MyHomePageState extends State<MyHomePage> {
  Mercure mercureClient;
  //...

  @override
  Future<void> initState() {
    super.initState();
    // ...
    initMercure();
  }
wallforfry commented 3 years ago

Hi @yurik94 ! We started to implement Flutter web support in August 2019 but we never released a stable version by lack of time and of need. The theoretically working code lay down in the feature-flutterweb branch but isn't fully tested.

You can update this branch from the current master and submit a pull request if you want. If I have some free time, I'll try to do it myself during the next weeks.