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

Improvements for Web Components #1444

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

marschall
Copy link
Contributor

Improvements that allow applications with Web Components to run with a lower overhead.

  • Save only a single action continuation. Since the back button does not work with Web Components in general we only need to save a single action continuation. This should keep sessions smaller.
  • Dedicated action continuation. Since the back button does not work with Web Components in general we can make use of an optimized action continuation that:
    • does not redirect.
    • does not capture state.
    • does not restore state.

In theory these classes could be used in general for "back button less" Seaside applications. However this is quite an advanced topic so I think it's ok to "burry" these in the WebComponents package. Let me know what you think.

Improvements that allow applications with Web Components to run with a lower overhead.
Copy link

codecov bot commented Oct 13, 2024

Codecov Report

Attention: Patch coverage is 75.70093% with 26 lines in your changes missing coverage. Please review.

Project coverage is 50.03%. Comparing base (0f7d6f7) to head (f6be4f2).

Files with missing lines Patch % Lines
...age/WASingleElementCache.class/instance/remove..st 0.00% 5 Missing ⚠️
...nContinuation.class/instance/basicPerformAction.st 0.00% 4 Missing ⚠️
...onentActionContinuation.class/instance/continue.st 0.00% 4 Missing ⚠️
...nSession.class/instance/createContinuationCache.st 0.00% 3 Missing ⚠️
...ActionContinuation.class/instance/jumpToAnchor..st 0.00% 3 Missing ⚠️
...tActionContinuation.class/instance/restoreState.st 0.00% 3 Missing ⚠️
...ctionContinuation.class/instance/shouldRedirect.st 0.00% 3 Missing ⚠️
...tsLibrary.class/instance/seasideWebComponentsJs.st 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1444      +/-   ##
==========================================
+ Coverage   49.42%   50.03%   +0.61%     
==========================================
  Files        9073     8946     -127     
  Lines       80086    79229     -857     
==========================================
+ Hits        39582    39645      +63     
+ Misses      40504    39584     -920     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@adriaon
Copy link

adriaon commented Oct 17, 2024

Is there a typo or two in https://github.com/marschall/Seaside/blob/master/repository/Seaside-WebComponents-Core.package/WAHeadlessComponent.class/README.md ?

Also, I wouldn't mind if the classes that are useful for SPA's are not buried, but more generally available. Perhaps in a SPA package?

@marschall
Copy link
Contributor Author

Is there a typo or two in https://github.com/marschall/Seaside/blob/master/repository/Seaside-WebComponents-Core.package/WAHeadlessComponent.class/README.md ?

Probably a rendering issue by GitHub. Check out the raw content

https://raw.githubusercontent.com/marschall/Seaside/refs/heads/master/repository/Seaside-WebComponents-Core.package/WAHeadlessComponent.class/README.md

Also, I wouldn't mind if the classes that are useful for SPA's are not buried, but more generally available. Perhaps in a SPA package?

What classes would you be interested in? WAWebComponentActionContinuation? Do you have a suggestion for a name?

Perhaps in a SPA package?

Maybe, but only if we have more than one class to go there.

@adriaon
Copy link

adriaon commented Oct 18, 2024

https://raw.githubusercontent.com/marschall/Seaside/refs/heads/master/repository/Seaside-WebComponents-Core.package/WAHeadlessComponent.class/README.md

Got it. Thanks

What classes would you be interested in? WAWebComponentActionContinuation? Do you have a suggestion for a name?

Perhaps in a SPA package?

Maybe, but only if we have more than one class to go there.

If I understand things correctly, i see

  • WAWebComponentActionContinuation
  • WASingleElementCache
  • WASingleContinuationSession

as candidates.

Maybe something like Seaside-SingleContinuation-Core as a name? Or maybe rename Seaside-WebComponents-Core as such?

Cheers,
Adriaan.

jbrichau
jbrichau previously approved these changes Oct 19, 2024
Copy link
Member

@jbrichau jbrichau left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for this!
I made a couple of code style suggestions in the detail comments.

I was first expecting a "single continuation session" to always reuse the same continuation, like what happens with ajax requests. I do a similar thing in WATurboRenderPhaseContinuation. However, I now realise that because the webcomponent re-renders its entire fragment, it's better to throw away the old rendercontext and indeed create an entire new continuation.

at: aKey ifAbsent: aBlock
^ key = aKey
ifTrue: [ value ]
ifFalse: [ aBlock value ]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ifFalse: [ aBlock value ]
ifFalse: aBlock

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I do this I get a code critic warning in Pharo

ifTrue: ifFalse: ifTrue:ifFalse: ifFalse:ifTrue: is used in a way that it can not be optimized.

keyAtValue: anObject ifAbsent: aBlock
^ value = anObject
ifTrue: [ key ]
ifFalse: [ aBlock value ]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ifFalse: [ aBlock value ]
ifFalse: aBlock

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some Pharo code critic warning if I do this.

@@ -0,0 +1,4 @@
processing
continue
"do not capture state"
Copy link
Member

Choose a reason for hiding this comment

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

Side-note: since we do not capture state, do we need the contents of the states instvar in this class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see what you meant. The question comes down to how much we want to tie WAFragmentRenderPhaseContinuation to WAFragmentRenderPhaseContinuation. Right now the states inst vars are still filled with WASnapshot instances due to two reasons:

  • WAFragmentRenderPhaseContinuation inheritsWARenderLoopContinuation >> #createActionContinuationWithContext: and send #snapshot:renderContext: to the action phase continuation class
  • WAWebComponentActionContinuation >> #handle: still sends ends up in WASessionContinuation >> #handle:

Copy link
Contributor Author

@marschall marschall left a comment

Choose a reason for hiding this comment

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

Added responses to review comments

at: aKey ifAbsent: aBlock
^ key = aKey
ifTrue: [ value ]
ifFalse: [ aBlock value ]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I do this I get a code critic warning in Pharo

ifTrue: ifFalse: ifTrue:ifFalse: ifFalse:ifTrue: is used in a way that it can not be optimized.

keyAtValue: anObject ifAbsent: aBlock
^ value = anObject
ifTrue: [ key ]
ifFalse: [ aBlock value ]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some Pharo code critic warning if I do this.

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

Successfully merging this pull request may close these issues.

3 participants