-
-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add options to turbo_stream_listen
#2447
base: 2.x
Are you sure you want to change the base?
Conversation
📊 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.
|
867707d
to
06ac699
Compare
src/Turbo/src/Twig/TwigExtension.php
Outdated
unset($options['subscribe'], $options['publish'], $options['additionalClaims']); | ||
} | ||
|
||
return $this->turboStreamListenRenderers->get($transport)->renderTurboStreamListen($env, $topic, $options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot pass options as third parameter, as the interface only declare "options" in docblock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure how to do that, could you explain it to me ?
src/Turbo/src/Twig/TwigExtension.php
Outdated
@@ -12,19 +12,24 @@ | |||
namespace Symfony\UX\Turbo\Twig; | |||
|
|||
use Psr\Container\ContainerInterface; | |||
use Symfony\Component\HttpFoundation\RequestStack; | |||
use Symfony\Component\Mercure\Authorization; | |||
use Symfony\UX\Turbo\Bridge\Mercure\TopicSet; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could/should probably use TopicSet here, as it's specific to Mercure and would keep things properly typed / isolated.
Or any strategy that does not impact users using a different solution than Mercure.
You should look at this PR and the discussion, as most challenges are identical
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see where I could use this object, could you add more details ?
06ac699
to
abcc723
Compare
abcc723
to
e95cbab
Compare
This allows to pass options to the EventSource, for example
{{ turbo_stream_listen('a_topic', 'default', { withCredentials: true }) }}
Or create specific auth cookie
{{ turbo_stream_listen('a_topic', 'default', { subscribe: '*' }) }}
This functionality is similar to how
mercure()
works