ampproject / ampproject/amphtml

Rename buildCallback and layoutCallback

Open
#31,046 2 comments 4 reactions 1 assignee Claimed by @samouri View on GitHub
Stale Type: Bug Type: Discussion/Question
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

**summary**
I think it would make sense to drop the `Callback` suffix from `buildCallback` and `layoutCallback`. The current naming was inspired by CustomElement callbacks, like `connectedCallback` and `disconnectedCallback`.

The CE names makes sense because they refer to how the functions are being called in response to an event that just happened. For build and layout, however, they don't make sense since they aren't called in response to an event that occurred, they are commands for the Element to perform an action.

Using buildCallback to demonstrate my point, here are what I believe the names signal to code authors:
- `buildCallback()`: implies build has already happened and the element now has a the opportunity to react to the event.
- `build()`: implies an element should build.

Note: this is a super low priority issue with no user impact, but its something has been bugging me for awhile.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.