Added AnimatedValueXY.removeAllListeners

Summary:
> Explain the **motivation** for making this change. What existing problem does the pull request solve?

`AnimatedValueX` has `removeAllListeners()` which is a convenient way to do cleanup when components unmount, but `AnimatedValueXY` was missing a similar method which doesn't really make sense. This change makes the two classes more similar, less confusing and more convenient.
Closes https://github.com/facebook/react-native/pull/11783

Differential Revision: D4397188

fbshipit-source-id: d10a0c9c7e0a83af015ec04f6facf965d95ea984
This commit is contained in:
Seph Soliman 2017-01-14 14:39:11 -08:00 committed by Facebook Github Bot
parent 237ee2ddf6
commit 6d2ae35bca
1 changed files with 6 additions and 0 deletions

View File

@ -1030,6 +1030,12 @@ class AnimatedValueXY extends AnimatedWithChildren {
delete this._listeners[id]; delete this._listeners[id];
} }
removeAllListeners(): void {
this.x.removeAllListeners();
this.y.removeAllListeners();
this._listeners = {};
}
/** /**
* Converts `{x, y}` into `{left, top}` for use in style, e.g. * Converts `{x, y}` into `{left, top}` for use in style, e.g.
* *