Skip to content
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

Struggle with use case #4

Closed
pySilver opened this issue Nov 9, 2022 · 3 comments
Closed

Struggle with use case #4

pySilver opened this issue Nov 9, 2022 · 3 comments

Comments

@pySilver
Copy link

pySilver commented Nov 9, 2022

Hey!

Thanks for the lib. I'm reading https://docs.stimulusreflex.com/rtfm/morph-modes to get better understanding of a real world benefits that morphdom brings comparing to typical Turbo.StreamActions (replace/update). Shame on me but I cannot find a good example where morphdom is better than typical stream update/replace action.

Would you be so kind to provide more info on this?

@pySilver
Copy link
Author

pySilver commented Nov 9, 2022

Funny I've just found your post here: https://twitter.com/marcoroth_/status/1549272819556667392

@pySilver pySilver closed this as completed Nov 9, 2022
@marcoroth
Copy link
Owner

Hey @pySilver, thanks for reaching out and bringing that up.

Yeah, there are some "edge-cases" where morph operations could come in handy, where a regular update/replace operation could cause some issues.

The most common one is loosing state which is stored on DOM elements or the reinitialization of Stimulus controllers if the root element or any children has controllers attached.

But that also depends how you write your Stimulus controllers. For some you actually want to trigger a reinitialization, for exmaple if your controller is responsible for initializing tooltips within the newly morphed HTML content.

But if your controller is responsible for handling audio/video you don't want that controller to be reinitialized because you would loose that state and cause the media to stop.

It might be worth to convert that Twitter thread into a proper blog post for better visibility!

Thanks!

@pySilver
Copy link
Author

pySilver commented Nov 9, 2022

@marcoroth thanks for the quick reply! Yes, I think any kind of streaming media would be the perfect use case for morphs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants