diff --git a/mercure.rst b/mercure.rst index 42ad9798d3c..125511f6f2b 100644 --- a/mercure.rst +++ b/mercure.rst @@ -282,6 +282,11 @@ URL in a dedicated HTML element: {{ mercure('https://example.com/books/1')|json_encode(constant('JSON_UNESCAPED_SLASHES') b-or constant('JSON_HEX_TAG'))|raw }} + +
+ Then retrieve it from your JS file: .. code-block:: javascript @@ -290,6 +295,9 @@ Then retrieve it from your JS file: const eventSource = new EventSource(url); // ... + // with Stimulus + this.eventSource = new EventSource(this.mercureUrlValue); + Mercure also allows subscribing to several topics, and to use URI Templates or the special value ``*`` (matched by all topics) as patterns: @@ -407,7 +415,7 @@ of the ``Update`` constructor to ``true``:: $update = new Update( 'https://example.com/books/1', json_encode(['status' => 'OutOfStock']), - true // private + private: true ); // Publisher's JWT must contain this topic, a URI template it matches or * in mercure.publish or you'll get a 401 @@ -704,6 +712,8 @@ enable it:: :alt: The Mercure panel of the Symfony Profiler, showing information like time, memory, topics and data of each message sent by Mercure. :class: with-browser +The Mercure hub itself provides a debug tool that can be enabled and available on `/.well-known/mercure/ui/` + Async dispatching -----------------