Skip to content

Extract signals into its own class#7240

Merged
dvoytenko merged 1 commit intoampproject:masterfrom
dvoytenko:fie14-signals2
Jan 30, 2017
Merged

Extract signals into its own class#7240
dvoytenko merged 1 commit intoampproject:masterfrom
dvoytenko:fie14-signals2

Conversation

@dvoytenko
Copy link
Copy Markdown
Contributor

The Signals object is used across AMP elements, ampdoc and friendly embeds and potentially more in the future. Signals can be used for analytics or other dependent functions.

This PR is a straightforward refactoring that extracts Signals class and its tests into a separate module. No functional code changes.

Copy link
Copy Markdown
Member

@cramforce cramforce left a comment

Choose a reason for hiding this comment

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

Was going to suggest this :)

* This object tracts signals and allows blocking until a signal has been
* received.
*/
export class Signals {
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.

An extra object allocation per element.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the cost of being able to track past events that maybe requested in the future. Can't see another option, tbh. But would be happy to discuss.

@cramforce
Copy link
Copy Markdown
Member

This is fine. Do we currently need signals on all elements? Or could elements opt-in?

@dvoytenko
Copy link
Copy Markdown
Contributor Author

@cramforce We are now using it for built signals and all elements build. There's no way to make it more selective and creating Signals is probably cheaper than creating lots of promises - the part where signals is fairly efficient.

@dvoytenko dvoytenko merged commit 87b2dc4 into ampproject:master Jan 30, 2017
@dvoytenko dvoytenko deleted the fie14-signals2 branch January 30, 2017 18:29
jridgewell pushed a commit to jridgewell/amphtml that referenced this pull request Jan 31, 2017
torch2424 pushed a commit to torch2424/amphtml that referenced this pull request Feb 14, 2017
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants