Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1bb295f

Browse files
committed
Merge branch '4.2'
* 4.2: [Mercure] Fix list rendering Improved the highlighting of JS examples in Mercure docs
2 parents8b5f415 +31b9bae commit1bb295f

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

‎mercure.rst‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,30 +189,29 @@ Subscribing to updates in JavaScript is straightforward:
189189

190190
..code-block::javascript
191191
192-
<script>
193192
constes=newEventSource('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,
201199
and to use URI Templates as patterns:
202200

203201
..code-block::javascript
204202
205-
<script>
206-
constu=newURL('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+
constu=newURL('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
constes=newEventSource(u);
212212
es.onmessage=e=> {
213213
console.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
315314
fetch('/books/1')// Has Link: <http://localhost:3000/hub>; rel="mercure"
316315
.then(response=> {
@@ -325,7 +324,6 @@ and to subscribe to it:
325324
constes=newEventSource(h);
326325
es.onmessage=e=>console.log(e.data);
327326
});
328-
</script>
329327
330328
Authorization
331329
-------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp