Skip to content

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

Merged
michalczaplinski merged 8 commits intotrunkfrom
docs/interactivity-api-get-server-state-and-context
Oct 21, 2024
Merged

Docs: Interactivity API - Add documentation for getServerState() and getServerContext()#66104
michalczaplinski merged 8 commits intotrunkfrom
docs/interactivity-api-get-server-state-and-context

Conversation

@michalczaplinski
Copy link
Copy Markdown
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
Copy Markdown
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.

@github-actions
Copy link
Copy Markdown

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 <czapla@git.wordpress.org>
Co-authored-by: DAreRodz <darerodz@git.wordpress.org>

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

@github-actions
Copy link
Copy Markdown

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
@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 [Package] 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 <czapla@git.wordpress.org>
Co-authored-by: DAreRodz <darerodz@git.wordpress.org>
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@luisherranz
Copy link
Copy Markdown
Member

Thanks, Michal.

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

Labels

[Package] Interactivity /packages/interactivity [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants