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

Y.Promise.EventNotifier: remove fulfilled promises from internal hash #36

Open
ItsAsbreuk opened this issue Jul 2, 2014 · 0 comments
Open

Comments

@ItsAsbreuk
Copy link

Because promises that are bound to the notifier get into the internal _targets, they never get freed by the GC. Even fulfilled promises remain in the hash, leading to an increasing internal hash.

The issue is resolved by changing addEvents into this:

        addEvents: function (promise) {
            var targets = this._targets;
            targets.push(promise);
            promise.catch(
                function() {
                    return true;
                }
            ).then(
                function() {
                    targets.splice(targets.indexOf(promise), 1);
                }
            );
            return Notifier.decorate(promise);
        }

Ragerds,
Marco

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

1 participant