Skip to content

Commit

Permalink
Added AnimatedValueXY.removeAllListeners
Browse files Browse the repository at this point in the history
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 #11783

Differential Revision: D4397188

fbshipit-source-id: d10a0c9c7e0a83af015ec04f6facf965d95ea984
  • Loading branch information
scarlac authored and facebook-github-bot committed Jan 14, 2017
1 parent 237ee2d commit 6d2ae35
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Libraries/Animated/src/AnimatedImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 6d2ae35

Please sign in to comment.