-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
[Turbo] Pass EventSource 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
06ac699
to
abcc723
Compare
abcc723
to
e95cbab
Compare
f92e643
to
e56b74c
Compare
Hey @smnandre, However, the last commit seems a bit off to me. Could you confirm if that's what you had in mind ? |
Hi seb-jean Guervyl gremo DRaichev and anyone who want to :) Well.... It’s time to lay all this out clearly! 😊 Could you share your ideal Developer Experience (DX) suggestions? Please clarify where and how you’d use this feature: Looking forward to your insights! |
turbo_stream_listen
turbo_stream_listen
e56b74c
to
4d9f2a9
Compare
TwigComponent errors are unrelated |
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.
@Fan2Shrek it took too much time, i'm sorry for this. Thank you very much for this work.
@seb-jean & @tibobaldwin thank you for the recent pokes :)
Hey @smnandre, thanks for the help! Unfortunately, there's still a problem with the |
4d9f2a9
to
961ef08
Compare
I found that Using Mercure to create the cookies causes the tests to fail. |
I promise you I did not remember this... but now it happens it feels a bit ironic 😆 Well, let's move on :) You can try this: #2447 (comment) The only think you cannot is "configure" a service from another bundle/bridge/etc. So if you find a way to inject the service directly it's perfect (just use ignoreOnInvalid to not pollute our code if there were a problem one day) If you don't, I'll have a look later during the night 🦇 or tomorrow |
583aab6
to
5b429a7
Compare
I adapted the code to use the Twig Mercure extension. |
Well well well ... 👼 (1/1)![]() Well well well .... 👼 (2/2) *
* @return string The URL of the hub with the appropriate "topic" query parameters (if any)
*/
public function mercure($topics = null, array $options = []): string https://github.com/symfony/mercure[•••]src/Twig/MercureExtension.php |
Does it work ? If not, what is missing here ? How do you test? |
I tested it on a small app with Mercure already set up. The only problem I’m facing is how to inject I’m not sure what the 'proper' way to solve this problem is. |
{ | ||
private StimulusHelper $stimulusHelper; | ||
|
||
public function __construct( | ||
private HubInterface $hub, | ||
StimulusHelper|StimulusTwigExtension $stimulus, | ||
private IdAccessor $idAccessor, | ||
private Environment $twig, |
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.
did you update the config for this argument ?
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.
Can I? The config is handled by MercureBundle.
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.
How so ?
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.
Isn't this the line that handles it?
https://github.com/symfony/mercure-bundle/blob/77435d740b228e9f5f3f065b6db564f85f2cdb64/src/DependencyInjection/MercureExtension.php#L211C17-L211C19
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.
Well... back to step1.
Honestly it makes not much sense to me MercureBundle is the one configuring classes on this bundle :|
Could you start a conversation on the MercureBundle repository and see what's the best way to handle this ?
0663176
to
ed131f3
Compare
ed131f3
to
a59fd33
Compare
Hey @smnandre, this finally looks good to me :) |
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