Provide a quick way to publish and consume messages on Mercure.

The features

This project use Dio as HTTP client for making get request and listen for server side event.

Consuming messages

import 'package:mercure_client/mercure_client.dart';

main() {
  final Mercure mercure = Mercure(
    'http://example.com/.well-known/mercure', // your mercure hub url
    '/books/{id}', // your mercure topic
  );

  mercure.subscribe((event) {
    print(event.data);
  });
}

Publishing Messages

Mercure.publish(
  url: 'http://example.com/.well-known/mercure',
  topic: '/books',
  data: 'some data',
).then((response) {
  print(response.statusCode);
});

Libraries

mercure_client