10000 Move capturing up to the state object by joeldrapper · Pull Request #880 · yippee-fun/phlex · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Move capturing up to the state object #880

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

Merged
merged 1 commit into from
Mar 17, 2025
Merged

Conversation

joeldrapper
Copy link
Collaborator
@joeldrapper joeldrapper commented Mar 17, 2025

In order to fix yippee-fun/phlex-rails#276, we need to simplify the capturing interface so it can be swapped out. This PR removes the ability to capture into an arbitrary buffer. Instead, it depends on reading the new buffer from the state within a capture block.

See yippee-fun/phlex-rails#279

Comment on lines +356 to 359
def vanish(...)
capture(...)
nil
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a reasonable simplification here. It allocates a string but I think it’s fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think so. The typical use case for vanish is that you'd be calling it with a block that shouldn't contain any direct element calls. So the performance optimization of Phlex::Vanish probably wasn't even being used much.

Comment on lines -19 to -26
def buffer
case @buffer
when Proc
@buffer.call
else
@buffer
end
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We never needed this.

Copy link
Contributor
@willcosgrove willcosgrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! capture still maintains its same contract so this can be a non-breaking update 💪

@joeldrapper joeldrapper marked this pull request as ready for review March 17, 2025 18:08
@joeldrapper joeldrapper merged commit 11a0d00 into main Mar 17, 2025
13 checks passed
@joeldrapper joeldrapper deleted the move-capture-to-state branch March 17, 2025 18:08
@peterberkenbosch
Copy link

<3

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

Successfully merging this pull request may close these issues.

Cache hit is not rendering output
3 participants
0