[Turbo] Add <turbo-mercure-stream-source> custom element#3505
[Turbo] Add <turbo-mercure-stream-source> custom element#3505seb-jean wants to merge 1 commit intosymfony:3.xfrom
<turbo-mercure-stream-source> custom element#3505Conversation
📊 Packages dist files size differenceThanks for the PR! Here is the difference in size of the packages dist files between the base branch and the PR.
|
|||||||||||||||
7a0d85f to
eb0b865
Compare
Kocal
left a comment
There was a problem hiding this comment.
Few (and maybe stupid) comments, I don't have such experience with UX Turbo, I trust you here 🤞🏻
| */ | ||
| public function renderTurboStreamListen(Environment $env, $topic, ?string $transport = null, array $options = []): string | ||
| { | ||
| trigger_deprecation('symfony/ux-turbo', '3.0', 'The "%s()" method is deprecated since Symfony UX 3.0, use "%s()" or the <twig:Turbo:Stream:From> Twig component instead. It will be removed in 4.0.', __METHOD__, __CLASS__.'::renderTurboStreamFrom'); |
There was a problem hiding this comment.
AFAIK there is no need to add both @deprecated and trigger_deprecation(), you must only use @deprecated
There was a problem hiding this comment.
The Symfony conventions require both @deprecated and trigger_deprecation(): https://symfony.com/doc/current/contributing/code/conventions.html#deprecating-code
There was a problem hiding this comment.
I don't see where it requires to have both @deprecated and trigger_deprecation() on the same method, it only show an example about deprecating a whole class 🤔
But it looks like you're right, I found one example on current Symfony version: https://github.com/symfony/symfony/blob/8e8f87c6fa5f47a431fc2f49bdbe601f6769e19d/src/Symfony/Component/Serializer/Exception/PartialDenormalizationException.php#L47-L52
Maybe our documentation could be improved
There was a problem hiding this comment.
For me, the documentation refers to both classes and methods. But as you pointed out, the documentation isn't very clear.
I think that with the example you cited, we can be sure we can include both.
f3fdefa to
6d0c62e
Compare
|
I'm getting an error related to the Should I modify |
This PR was merged into the 3.x branch. Discussion ---------- Remove old "deprecated: 2.x" directives | Q | A | -------------- | --- | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | yes <!-- if yes, also update UPGRADE-*.md and src/**/CHANGELOG.md --> | Documentation? | yes <!-- required for new features, or documentation updates --> | Issues | | License | MIT Update doctor rst config and documentation for 3.x Related to #3505 (comment) Commits ------- 58d8b5e Remove old "deprecated: 2.x" directives
|
I just merged #3515, you can rebase this one 🙏🏻 |
6d0c62e to
11c3b95
Compare
|
I just rebased |
Summary
This PR introduces a native HTML custom element
<turbo-mercure-stream-source>to replace themercure-turbo-streamStimulus controller for subscribing to Mercure topics and receiving Turbo Stream updates.What's new
<turbo-mercure-stream-source>custom element (mercure_stream_source_element.js): manages theEventSourcelifecycle (connect, disconnect, reconnect on attribute change) and sets aconnectedattribute when the SSE connection is establishedStreamSourceUrlGeneratorinterface: decouples URL generation from rendering, making custom transports easier to implementMercureStreamSourceUrlGenerator: Mercure implementation, delegates authorization cookie handling to the Mercure Bundle for private topicsturbo_stream_from()Twig function and<twig:Turbo:Stream:From>Twig component: the new way to subscribe to Mercure topics in templatesDeprecations
turbo_stream_listen()Twig function → useturbo_stream_from()or<twig:Turbo:Stream:From>TurboStreamListenRendererInterface→ implementStreamSourceUrlGeneratorinsteadTurboStreamListenRenderer→ useMercureStreamSourceUrlGeneratorTopicSetmercure-turbo-streamStimulus controller → replaced by the<turbo-mercure-stream-source>custom element, auto-imported viaturbo-coreThanks to @smnandre for opening issue #2460, which inspired this PR. 🙏