dart_mercure 0.1.3-dev.1 copy "dart_mercure: ^0.1.3-dev.1" to clipboard
dart_mercure: ^0.1.3-dev.1 copied to clipboard

outdated

A library to communicate with dunglas/mercure. This library allow publish/subscribe on Mercure Hub. Can be use to create firebase like notification system.

Dart library for dunglas/mercure

pipeline status pub package

  • This library allow to communicate with dunglas/mercure.
  • You can publish and subscribe to topic on Mercure Hub.
  • It can be easily integrate with other package for create firebase like notification system.

license.

Usage #

A basic usage example of publish/subscribe :

import 'package:dart_mercure/dart_mercure.dart';

main() {

  // Token generate with "mercure" JWT_KEY
  String token = "YOUR_JWT_TOKEN";
  String hub_url = "http://MERCURE_HUB_URL/hub";
  String topic = "http://YOUR_TOPIC/FOO";

  // For dart or flutter :
  Mercure mercure = Mercure(token: token, hub_url: hub_url);
  // For flutter web :
  // Mercure mercure = Mercure(token: token, hub_url: hub_url, client: BrowserClient());

  // Subscribes to topics
  mercure.subscribeTopics(topics: <String> [topic, "ANOTHER_TOPIC"], onData: (Event event) {
    print(event.data);
  });

  // Subscribe to topic
  mercure.subscribeTopic(topic: topic, onData: (Event event) {
    print(event.data);
  });

  // Publish on topic
  mercure.publish(topic: topic, data: "DATA").then((status) {
    if(status == 200) {
      print("Message Sent");
    }
    else {
      print('Message Failed with code : $status');
    }
  });
}

Features and bugs #

Please file feature requests and bugs at the issue tracker

7
likes
0
pub points
0%
popularity

Publisher

verified publisherwallforfry.fr

A library to communicate with dunglas/mercure. This library allow publish/subscribe on Mercure Hub. Can be use to create firebase like notification system.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

http, meta, w3c_event_source

More

Packages that depend on dart_mercure