@@ -189,30 +189,29 @@ Subscribing to updates in JavaScript is straightforward:
189189
190190.. code-block :: javascript
191191
192- < script>
193192 const es = new EventSource (' http://localhost:3000/hub?topic=' + encodeURIComponent (' http://example.com/books/1' ));
194193 es .onmessage = e => {
195194 // Will be called every time an update is published by the server
196195 console .log (JSON .parse (e .data ));
197196 }
198- < / script>
199197
200198 Mercure also allows to subscribe to several topics,
201199and to use URI Templates as patterns:
202200
203201.. code-block :: javascript
204202
205- < script >
206- const u = new URL (' http://localhost:3000/hub' ); // URL is a built-in JavaScript class to manipulate URLs
203+ // URL is a built-in JavaScript class to manipulate URLs
204+ const u = new URL (' http://localhost:3000/hub' );
207205 u .searchParams .append (' topic' , ' http://example.com/books/1' );
208- u .searchParams .append (' topic' , ' http://example.com/books/2' ); // Subscribe to updates of several Book resources
209- u .searchParams .append (' topic' , ' http://example.com/reviews/{id}' ); // All Review resources will match this pattern
206+ // Subscribe to updates of several Book resources
207+ u .searchParams .append (' topic' , ' http://example.com/books/2' );
208+ // All Review resources will match this pattern
209+ u .searchParams .append (' topic' , ' http://example.com/reviews/{id}' );
210210
211211 const es = new EventSource (u);
212212 es .onmessage = e => {
213213 console .log (JSON .parse (e .data ));
214214 }
215- < / script>
216215
217216 .. tip ::
218217
@@ -293,7 +292,7 @@ by using the ``AbstractController::addLink`` helper method::
293292 public function __invoke(Request $request): JsonResponse
294293 {
295294 // This parameter is automatically created by the MercureBundle
296- $hubUrl = $this->getParameter('mercure.default_hub');
295+ $hubUrl = $this->getParameter('mercure.default_hub');
297296
298297 // Link: <http://localhost:3000/hub>; rel="mercure"
299298 $this->addLink($request, new Link('mercure', $hubUrl));
@@ -310,7 +309,6 @@ and to subscribe to it:
310309
311310.. code-block :: javascript
312311
313- < script>
314312 // Fetch the original resource served by the Symfony web API
315313 fetch (' /books/1' ) // Has Link: <http://localhost:3000/hub>; rel="mercure"
316314 .then (response => {
@@ -325,7 +323,6 @@ and to subscribe to it:
325323 const es = new EventSource (h);
326324 es .onmessage = e => console .log (e .data );
327325 });
328- < / script>
329326
330327 Authorization
331328-------------
0 commit comments