@@ -189,30 +189,29 @@ Subscribing to updates in JavaScript is straightforward:
189189
190190..code-block ::javascript
191191
192- < script>
193192const es = new EventSource (' http://localhost:3000/hub?topic=' + encodeURIComponent (' http://example.com/books/1' ));
194193es .onmessage = e => {
195194// Will be called every time an update is published by the server
196195console .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' );
207205u .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
211211const es = new EventSource (u);
212212es .onmessage = e => {
213213console .log (JSON .parse (e .data ));
214214 }
215- < / script>
216215
217216 ..tip ::
218217
@@ -222,6 +221,7 @@ and to use URI Templates as patterns:
222221 ..image ::/_images/mercure/chrome.png
223222
224223 To use it:
224+
225225 * open the DevTools
226226 * select the "Network" tab
227227 * click on the request to the Mercure hub
@@ -293,7 +293,7 @@ by using the ``AbstractController::addLink`` helper method::
293293 public function __invoke(Request $request): JsonResponse
294294 {
295295 // This parameter is automatically created by the MercureBundle
296- $hubUrl = $this->getParameter('mercure.default_hub');
296+ $hubUrl = $this->getParameter('mercure.default_hub');
297297
298298 // Link: <http://localhost:3000/hub>; rel="mercure"
299299 $this->addLink($request, new Link('mercure', $hubUrl));
@@ -310,7 +310,6 @@ and to subscribe to it:
310310
311311..code-block ::javascript
312312
313- < script>
314313// Fetch the original resource served by the Symfony web API
315314fetch (' /books/1' )// Has Link: <http://localhost:3000/hub>; rel="mercure"
316315 .then (response => {
@@ -325,7 +324,6 @@ and to subscribe to it:
325324const es = new EventSource (h);
326325es .onmessage = e => console .log (e .data );
327326 });
328- < / script>
329327
330328 Authorization
331329-------------