-
-
Notifications
You must be signed in to change notification settings - Fork 356
[Turbo] Simplify stream negotiation #217
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] Simplify stream negotiation #217
Conversation
38748a2
to
e812d72
Compare
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 really like that. Here are some comments.
1636d22
to
b6de1e3
Compare
Thanks Kévin. |
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.
Great work. Thank you 👍
$response = $this->render('task/success.html.twig', ['task' => $task]); | ||
} | ||
|
||
return $response->setVary('Accept'); |
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.
👍
public const STREAM_FORMAT = 'turbo_stream'; | ||
public const STREAM_MEDIA_TYPE = 'text/vnd.turbo-stream.html'; | ||
|
||
public function boot(): void |
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.
Didn't know about this method. Nice to know something like this exists.
@weaverryan anything blocking here for a release? |
/cc @florentdestremau this relates to your talk at the meetup yesterday: TurboStreamResponse is gone, see updated doc in the PR. |
Indeed, but you still need to specify the request format ? I feel like you still need to "think" about changing something in your code when you switch from a turbo-frame to a turbo-stream. Or did I misread ? |
The call to |
I'm not sure I understand the improvement here 🤔 . If you can either return a turbo-frame (e.g. Form Invalid → 400, or Form display → 200) or a turbo-stream (e.g. Form Submitted Successfully → 302 + 200 or 200) then you can't always set the request format, so you don't really "gain" code length vs extending the TurboStreamRequest object in your |
Other point: I'm thankful for you @nicolas-grekas pointing this PR out, because it causes a BC-break in our code: the object TurboStreamResponse is removed in a minor version so I feel like it should have been deprecated instead, no ? For now we downgraded to 2.0.1 until we take the time to update our codebase with 2.1 |
The Symfony/UX component is still marked as |
At least from an internal pov, this removes a listener, which is a net win. About userland, that's similar yes, although more straightforward now I believe. |
@alexander-schranz Yeah I kinda suspected that, but I can't find an explicit message mentioning this, would be interesting to make sur it is 😉 |
This patch replaces the ad-hoc content negotiation system for Turbo Streams used by the bundle. HttpFoundation's native content negotiation features are now used instead. This greatly simplifies the code, which is security-sensitive, and improves DX (content negotiation is now consistent with how it is handled in the rest of the framework).
Replaces #214. Needs #215 and symfony/symfony#44980.