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

Docs: Interactivity API - Add documentation for getServerState() and getServerContext() #66104

Merged

Conversation

michalczaplinski
Copy link
Contributor

@michalczaplinski michalczaplinski commented Oct 14, 2024

getServerState() and getServerContext() functions were added to the Interactivity API in #65151

This PR adds documentation for both of them. Those functions are going to ship in WP 6.7.

Additionally, the files are now formatter with prettier as they should be.

Copy link
Contributor

@DAreRodz DAreRodz left a comment

Choose a reason for hiding this comment

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

Great docs, @michalczaplinski, especially the part in the Core Concepts guide. 👏

I've left a couple of questions/suggestions.

Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: michalczaplinski <[email protected]>
Co-authored-by: DAreRodz <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

Flaky tests detected in 2330492.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11443229130
📝 Reported issues:

@michalczaplinski michalczaplinski merged commit 119cacc into trunk Oct 21, 2024
62 checks passed
@michalczaplinski michalczaplinski deleted the docs/interactivity-api-get-server-state-and-context branch October 21, 2024 16:10
@github-actions github-actions bot added this to the Gutenberg 19.6 milestone Oct 21, 2024
@cbravobernal cbravobernal added the [Packages] Interactivity /packages/interactivity label Oct 30, 2024
karthick-murugan pushed a commit to karthick-murugan/gutenberg that referenced this pull request Nov 13, 2024
…d `getServerContext()` (WordPress#66104)

* Add documentation on `getServerState()` and `getServerContext()`

* update heading level

* Undelete the "Conclusion"

* Fix link to the documentation

* update link to router docs

* clarify about context

* add reference to @wordpress/router

Co-authored-by: michalczaplinski <[email protected]>
Co-authored-by: DAreRodz <[email protected]>
Copy link
Member

@luisherranz luisherranz left a comment

Choose a reason for hiding this comment

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

Sorry for being late to the party 😄

Apart from those two small changes could we add a clarification that, since these are reactive, if the value of a property doesn’t change, the watch callback will not re-trigger? Does that make sense?


```php
<?php
wp_interactivity_context( 'myPlugin', array(
Copy link
Member

Choose a reason for hiding this comment

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

wp_interactivity_context should be wp_interactivity_data_wp_context and be used inside an HTML tag.


### When to Use

Whenever you have interactive blocks that rely on global state that may change due to navigation events, ensuring consistency across different parts of your application.
Copy link
Member

Choose a reason for hiding this comment

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

Whenever you have interactive blocks that rely on global state or local context that may change due to navigation events, ensuring consistency across different parts of your application.

@michalczaplinski
Copy link
Contributor Author

@luisherranz Thanks for taking a look! I've implemented your comments in #67499

@luisherranz
Copy link
Member

Thanks, Michal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Packages] Interactivity /packages/interactivity [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants