-
Notifications
You must be signed in to change notification settings - Fork 21
How to decide what to implement? #4
Comments
Hey @davish, it looks like some great work has already been done here! I can see this project being very popular with Django devs. I think your proposal of trying to stick as close as possible to the Rails project is spot on. However, as you mentioned there's some significant differences between Rails and Django that will need to be addressed. Specifically, it seems to me Rails has more mature Websocket support that enables easier integration with Turbo Streams. However, I'm not sure it really matters that much. I've worked with Django for over 7 years now and realtime updating features tend to be pretty rare and will generally require custom JS anyway. For my projects even just having solid Drive and Frame integration would be huge. I'm wondering if this project could ship a v1 without Stream support at first? This would allow us to focus on a great Drive and Frame experience and get feedback on that before adding Stream. I've added a proposal for a Cheers! |
Hey @blopker! I agree with you that probably the most important thing is to get good helpers for turbo frames, since that's the most immediately applicable part of Turbo (along with Drive, which I don't think requires much special configuration) to projects. I do think that using turbo streams over HTTP (submit a form to create an item, the form responds with a stream which appends the new item to an existing list) is also a pattern that we should readily support from the get-go. With regards to websockets, I agree that it's more niche, but the I'll take a look at your |
Great! Yes, I didn't mean to imply that we shouldn't have Stream support or that what we currently have is not good. I got the current support working in the example app and it's super cool. I'm just thinking that a) Frames are going to be used the most and b) Stream support may take a bit to get right and we could release without it so it's not blocking. My other thought is that Stream support could be optional. This is so that people not using ASGI, like many older apps and apps that just don't need async, could still use the other Turbo support. I'd think the only effort here would be to make sure this package still works without |
That all makes sense! It seems like we're in agreement :) |
A few thoughts after spending a few days converting some fairly big projects over to Hotwire:
I've not looked at lazy loading yet; at first glance this should just work with plain responses, but it might not. Still, you don't need to set up channels for common use cases. tl;dr; most of the work was in writing helpers/response classes for views, template tags didn't do much, streams are more useful and used than frames, and Hotwire/Turbo is still very early beta and there's quite a few missing features and lack of docs/examples that hopefully will be addressed going forward. |
Good stuff! For 2, I haven't tested this, but from the Turbo documentation I'd assume just rendering all those turbo-stream tags in a normal response (not a streaming response) would work as well? I only ask since streaming responses are harder to gzip. |
Here's a concrete example (in production, you can go to https://audiotrails.io/account/signup/ and try it out):
|
With regards to the issue @danjac's running into around Turbo Frames and form responses, I also agree with @blopker that this works for me without issue. I replaced the default class MessageForm(ModelForm):
class Meta:
model = Message
fields = ["text", "confirm"]
def clean_confirm(self):
if not self.cleaned_data["confirm"]:
raise ValidationError(["You must confirm message"], code="invlaid")
return self.cleaned_data["confirm"] Along with adding The issue might have been that the form template did not include the I need to do some more investigation here, but I'd guess that you can return a response that contains both a Stream update along with a new Frame to reset the form after submission |
What issue is this? I just mentioned that the right approach is to return a stream rather than a frame with a form response. This is the right practice as per the Turbo docs. The problem is when you want to trigger a frame/stream from inside JS (e.g. from a fetch()) where you need to do something slightly more complicated than a simple form submit/link. |
Closing this issue, since discussion has moved to Slack (join here for anyone reading this!) |
I'm wondering what a good way to move forward is. Should we add utilities as people's projects seem to need them? Should we look at what's offered in hotwired/turbo-rails right now and port it over to Python? The second seems to make sense to me, but I personally don't have any experience with Ruby and have had trouble in the past reading through Rails codebases. If anyone else has experience in that area then I'd love to work with them!
The text was updated successfully, but these errors were encountered: