Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduces an optional mechanism for advanced advertising techniques #1214

Merged
merged 1 commit into from
Dec 21, 2015

Conversation

cramforce
Copy link
Member

…to manipulate incoming ad configuration in a callback function.

This is only available for publishers who host the ad iframe themselves.
With that they can obviously do whatever they want, but with this there is a larger incentive to stay within the AMP system and don't rely on implicit APIs (such as how we pass in configuration).

Increases test coverage for integration.js.

Fixes #1210

'Origin should have been validated');
run(type, win, data);
if (configCallback) {
configCallback(data, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not pass the data object, instead of counting on mutation?

configCallback(data, (data) => run(type, win, data));

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking about it, but it makes the signature of the callback harder to document.

Is your intuition to do it anyway?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yah, I tend not to grok "mutate this object" APIs. Either passing the data (or returning it) makes things much more clear, but we can't support async calls with the return value.

Copy link
Member

Choose a reason for hiding this comment

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

agree with @jridgewell here from an API standpoint. the closer the locality the better. easier to refactor (pure functions etc.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool.

I hope you are fine with me not copying the data, though :)

So, it isn't really pure.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yah, I don't expect anyone to do an immutable object. It just makes it easier to understand what's being passed as the configured object now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

expect(called).to.be.false;
called = true;
expect(myWin).to.equal(win);
expect(myData).to.equal(myData);
Copy link
Contributor

Choose a reason for hiding this comment

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

noop?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed to what it was supposed to be.

@cramforce cramforce force-pushed the 3p-config-callback branch 2 times, most recently from 7fa6d07 to 477f628 Compare December 21, 2015 22:43
// Don't actually call setTimeout here. This should only serve as an
// example that is OK to call the done callback asynchronously.
setTimeout(function() {
done();
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to update the example.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@jridgewell
Copy link
Contributor

LGTM.

to manipulate incoming ad configuration in a callback function.

This is only available for publishers who host the ad iframe themselves.
With that they can obviously do whatever they want, but with this there is a larger incentive to stay within the AMP system and don't rely on implicit APIs (such as how we pass in configuration).

Fixes ampproject#1210
@cramforce cramforce added the LGTM label Dec 21, 2015
cramforce added a commit that referenced this pull request Dec 21, 2015
Introduces an optional mechanism for advanced advertising techniques
@cramforce cramforce merged commit 289c2c2 into ampproject:master Dec 21, 2015
@cramforce cramforce deleted the 3p-config-callback branch December 21, 2015 23:04
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.

3 participants