@@ -282,6 +282,11 @@ URL in a dedicated HTML element:
282
282
{{ mercure('https://example.com/books/1')|json_encode(constant('JSON_UNESCAPED_SLASHES') b-or constant('JSON_HEX_TAG'))|raw }}
283
283
</script>
284
284
285
+ <!-- with Stimulus -->
286
+ <div {{ stimulus_controller('my-controller', {
287
+ mercureUrl: mercure('https://example.com/books/1'),
288
+ }) }}>
289
+
285
290
Then retrieve it from your JS file:
286
291
287
292
.. code-block :: javascript
@@ -290,6 +295,9 @@ Then retrieve it from your JS file:
290
295
const eventSource = new EventSource (url);
291
296
// ...
292
297
298
+ // with Stimulus
299
+ this .eventSource = new EventSource (this .mercureUrlValue );
300
+
293
301
Mercure also allows subscribing to several topics,
294
302
and to use URI Templates or the special value ``* `` (matched by all topics)
295
303
as patterns:
@@ -407,7 +415,7 @@ of the ``Update`` constructor to ``true``::
407
415
$update = new Update(
408
416
'https://example.com/books/1',
409
417
json_encode(['status' => 'OutOfStock']),
410
- true // private
418
+ private: true
411
419
);
412
420
413
421
// 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::
704
712
:alt: The Mercure panel of the Symfony Profiler, showing information like time, memory, topics and data of each message sent by Mercure.
705
713
:class: with-browser
706
714
715
+ The Mercure hub itself provides a debug tool that can be enabled and available on `/.well-known/mercure/ui/ `
716
+
707
717
Async dispatching
708
718
-----------------
709
719
0 commit comments