Skip to content

Commit 14df603

Browse files
committed
Add note about htmx/hotwire
1 parent 2144c0f commit 14df603

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

README.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,10 @@ Publisher::publish($update);
319319

320320
#### Publishing Rendered Views
321321

322-
Use the `ViewUpdate` class to automatically render CakePHP views or elements and publish the rendered HTML:
322+
Use the `ViewUpdate` class to automatically render CakePHP views or elements and publish the rendered HTML.
323+
324+
> [!NOTE]
325+
> This is especially handy when using JavaScript frameworks like [htmx](https://htmx.org/) (for instance, using the [htmx-sse extension](https://htmx.org/extensions/sse/)), [Hotwire](https://hotwired.dev/) (with [Turbo Streams](https://turbo.hotwired.dev/handbook/streams)), or similar reactive libraries, which can consume and swap HTML fragments received over Mercure for seamless real-time UI updates.
323326
324327
```php
325328
use Mercure\Publisher;
@@ -383,19 +386,6 @@ $update = (new ViewUpdate('https://example.com/users/123/messages'))
383386
Publisher::publish($update);
384387
```
385388

386-
> [!NOTE]
387-
> **View Class Configuration:** By default, `ViewUpdate` uses CakePHP's automatic view class selection (your `AppView` if it exists, otherwise the base `View` class). You can override this by setting `view_class` in your configuration:
388-
>
389-
> ```php
390-
> // In config/app_mercure.php
391-
> return [
392-
> 'Mercure' => [
393-
> 'view_class' => \App\View\CustomView::class,
394-
> // ... other config
395-
> ],
396-
> ];
397-
> ```
398-
399389
### Subscribing to Updates
400390

401391
The plugin provides a View Helper to generate Mercure URLs in your templates.

0 commit comments

Comments
 (0)