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

Allow add/remove listeners in callbacks (#119) #121

Merged
merged 1 commit into from
Sep 28, 2016

Conversation

odinho
Copy link
Contributor

@odinho odinho commented Sep 23, 2016

Using a callback to mutate the listeners (e.g. removing yourself), previously
changed the iterated array, causing bugs. Remove the problem by always copying
the array, so on()/off() become safe to call at any time.

Using a callback to mutate the listeners (e.g. removing yourself), previously
changed the iterated array, causing bugs.  Remove the problem by always copying
the array, so on()/off() become safe to call at any time.
@odinho odinho force-pushed the mutation_safe_listeners branch from 84bfab7 to 53d5a4f Compare September 23, 2016 10:02
@odinho
Copy link
Contributor Author

odinho commented Sep 23, 2016

Also added a test, because why not.

@dmlap
Copy link
Member

dmlap commented Sep 24, 2016

Awesome. LGTM

@imbcmdth
Copy link
Member

LGTM

@dmlap dmlap merged commit ea1e159 into videojs:master Sep 28, 2016
@dmlap
Copy link
Member

dmlap commented Sep 28, 2016

Thanks for the contribution, @odinho!

aN0obIs pushed a commit to aN0obIs/mux.js that referenced this pull request Apr 28, 2017
Using a callback to mutate the listeners (e.g. removing yourself), previously
changed the iterated array, causing bugs.  Remove the problem by always copying
the array, so on()/off() become safe to call at any time.
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.

3 participants