Skip to content

Update amp-bind docs#7216

Merged
dreamofabear merged 2 commits intoampproject:masterfrom
dreamofabear:bind-update-docs
Jan 27, 2017
Merged

Update amp-bind docs#7216
dreamofabear merged 2 commits intoampproject:masterfrom
dreamofabear:bind-update-docs

Conversation

@dreamofabear
Copy link
Copy Markdown

  • Rework amp-bind.md to use less jargon and update supported bindable attributes
  • Update amp-actions-and-events.md with new event data syntax, amp-state component, and AMP.setState action

/to @bpaduch /cc @ericlindley-g

The **scope** is mutable implicit document state that binding expressions may reference. The scope may be initialized with a new AMP component `<amp-state>`. Changes to the scope happen through user actions, e.g. clicking a `<button>` or switching slides on an `<amp-carousel>`.

A **digest** is an evaluation of all binding expressions. Since scope is mutable and expressions can reference the scope, the evaluated result of expressions may change over time. Bound elements are updated as a result of a digest.
A data binding is a special attribute that links an element to a custom [expression](#expressions). Expressions may reference implicit mutable JSON state. When that state is changed, expressions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Add "an" before "implicit"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done.

`amp-bind` expressions are JS-like with some important differences:

- Expressions only have access to the **scope**, not globals like `window` or `document`
- Expressions may only access JSON state in `<amp-state>` and that set by the `AMP.setState` action
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This sentence is slightly confusing because of the "and that set by" - what is set by the action? Is it the expression or the state? I think it's the state, so consider rewriting it as follows:

Expressions may only access the JSON state specified in <amp-state>, and that state is set by the AMP.setState action.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point.

Simplified to "...may only access the implicit JSON state." I think this suffices since we describe what that state is and how to modify it above.

Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

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

See comments.

@dreamofabear dreamofabear merged commit f33b581 into ampproject:master Jan 27, 2017
@dreamofabear dreamofabear deleted the bind-update-docs branch January 27, 2017 18:30
@dreamofabear
Copy link
Copy Markdown
Author

Thanks Barb!

jridgewell pushed a commit to jridgewell/amphtml that referenced this pull request Jan 31, 2017
* update bind docs

* barb's comments
torch2424 pushed a commit to torch2424/amphtml that referenced this pull request Feb 14, 2017
* update bind docs

* barb's comments
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
* update bind docs

* barb's comments
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.

2 participants