From 6d2ae35bca7c5a35e9c537880ebb2f3d5cbaec76 Mon Sep 17 00:00:00 2001 From: Seph Soliman Date: Sat, 14 Jan 2017 14:39:11 -0800 Subject: [PATCH] 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 --- Libraries/Animated/src/AnimatedImplementation.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Libraries/Animated/src/AnimatedImplementation.js b/Libraries/Animated/src/AnimatedImplementation.js index 074794d88c96ee..9c6151acce2ad4 100644 --- a/Libraries/Animated/src/AnimatedImplementation.js +++ b/Libraries/Animated/src/AnimatedImplementation.js @@ -1030,6 +1030,12 @@ class AnimatedValueXY extends AnimatedWithChildren { 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. *