Skip to content

addEventHandler implementation appears to be imcomplete #15

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

Closed
nealrosen opened this issue Jan 12, 2023 · 4 comments
Closed

addEventHandler implementation appears to be imcomplete #15

nealrosen opened this issue Jan 12, 2023 · 4 comments

Comments

@nealrosen
Copy link

Here are some of the things I'm seeing that cause me to believe this command is not fully implemented. Please let me know if I'm missing something.

  • I'm seeing a return value from __gpp('addEventHandler') of {param: undefined, next: undefined, callback: ƒ}, which does not match the IAB spec.
  • Only the stub code includes an eventName property in the response
  • I am unable to trigger an event to fire. After the CMP has loaded, I tried calling cmpApi.setGppString() then cmpApi.fireUpdate().
@chuff
Copy link
Contributor

chuff commented Jan 14, 2023

I believe this should now be working in 3.0.7. I also removed the cmpapi update method and replaced it with a few methods that reflect the defined event types from the spec. I also updated the stub so that the cmpapi could retrieve the stub queued event listeners. Let me know.

@nealrosen
Copy link
Author

Looks much better. I'm not clear why CMPs would need to call the cmpApi.fireEvent() to trigger another event to callers of the addEventListener command. For example, shouldn't calling cmpApi.setCmpStatus() be sufficient to trigger the event? In any case, I'm closing this issue because you have addressed the issues I raised.

FYI, there are additional issues with the addEventListener command, and frankly all others. It is due to the stub code (both from IAB docs and this implementation) making the assumption that all commands support only callbacks. Most commands do not support callbacks, only directly returning with some value. The stub does not pass returned values in postMessage calls to iframes. There is an issue and PR related to this on the documentation repo. I am working with Jan Winkler on this.

@chuff
Copy link
Contributor

chuff commented Jan 18, 2023

I'm open to suggestion on the fire methods. The "cmpStatus", "cmpDisplayStatus", and "error" events don't currently require a separate fireEvent call. The only one that does is "sectionChange". I implemented it that way so that the event handler could receive one event when all of the fields are set rather than one each time the "setFieldValue" method is called. The generic fireEvent method was actually put in there to handle the generic event from the spec "[API.prefix] or [API-prefix].[Eventname]".

@nealrosen
Copy link
Author

Oh ok, I didn't realize the cmpStatus event doesn't require a separate fireEvent call. Thanks.

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

No branches or pull requests

2 participants