You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
amp-bind allows developers to create interactive pages that can change content and show/hide different sections through user interactions. In some cases, it would be useful for an AMP viewer to be able to “deep-link” the user into a specific part of the page by setting the page’s AMP state.
Proposal
We should make amp-bind support a new message from the viewer called premutate which sets the amp-bind state of the AMP doc and re-computes all bindings. The message payload would have a single key state whose value is the state to set in the page. In order to allow a given AMP doc to be premutated like this, the page developer would have to add an overridable attribute to any amp-states that they would like to allow to be premutated by the viewer. The AMP doc responds to the premutate message with a list of the top-level state keys that were set.
The foo state gets updated (because it has the overridable attribute), but the bar state doesn’t (because it doesn’t have the overridable attribute). The AMP doc would respond with the following message:
Background
amp-bind allows developers to create interactive pages that can change content and show/hide different sections through user interactions. In some cases, it would be useful for an AMP viewer to be able to “deep-link” the user into a specific part of the page by setting the page’s AMP state.
Proposal
We should make amp-bind support a new message from the viewer called
premutate
which sets the amp-bind state of the AMP doc and re-computes all bindings. The message payload would have a single keystate
whose value is the state to set in the page. In order to allow a given AMP doc to be premutated like this, the page developer would have to add anoverridable
attribute to anyamp-state
s that they would like to allow to be premutated by the viewer. The AMP doc responds to the premutate message with a list of the top-level state keys that were set.Example
For the following AMP document:
If the viewer sent a
premutate
message with:The resulting state would be:
The
foo
state gets updated (because it has theoverridable
attribute), but thebar
state doesn’t (because it doesn’t have theoverridable
attribute). The AMP doc would respond with the following message:The text was updated successfully, but these errors were encountered: