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

Proposal: Add an isAnimated(val) existential method #9

Closed
lelandrichardson opened this issue Feb 28, 2016 · 7 comments
Closed

Proposal: Add an isAnimated(val) existential method #9

lelandrichardson opened this issue Feb 28, 2016 · 7 comments

Comments

@lelandrichardson
Copy link
Contributor

var Animated = require('animated');
var anim = new Animated.Value(123);
var interp = anim.interpolate({ ... });
Animated.isAnimated(anim) // true
Animated.isAnimated(interp) // true
Animated.isAnimated(123) // false

This would be a good API to provide people for detecting whether or not a given value is an animated value or not. This could be used, for example, to produce PropTypes helpers for the library.

@gre
Copy link
Contributor

gre commented Feb 28, 2016

Big +1 for this

Le dim. 28 févr. 2016 17:47, Leland Richardson notifications@github.com a
écrit :

var Animated = require('animated');var anim = new Animated.Value(123);var interp = anim.interpolate({ ... });Animated.isAnimated(anim) // trueAnimated.isAnimated(interp) // trueAnimated.isAnimated(123) // false

This would be a good API to provide people for detecting whether or not a
given value is an animated value or not. This could be used, for example,
to produce PropTypes helpers for the library.


Reply to this email directly or view it on GitHub
#9.

@browniefed
Copy link
Member

Yeah I think this is great, although it'll have to pair nicely with however we decide to move forward with custom animated values. Whether that is just extending AnimatedWithChildren or otherwise.

@lelandrichardson
Copy link
Contributor Author

@browniefed i'm working on a proposal for that right now. Either way, it should work fine. The test would basically just check: value instanceof Animated, but Animated itself wouldn't be an exported class. However we create new animated shapes, they would inevitably inherit from Animated

@browniefed
Copy link
Member

Tis what I figured 👍

@vjeux
Copy link
Collaborator

vjeux commented Feb 29, 2016

Really smart! I've been struggling to figure out how to encode that. Make it happen :)

@gre
Copy link
Contributor

gre commented Feb 29, 2016

@lelandrichardson if Animated/AnimatedWithChildren is not exposed, how can a third party library implement his own Animated? Will the library expose ways to create an Animated class?
My use-case is animated over uniforms for gl-react: https://github.com/ProjectSeptemberInc/gl-react/blob/master/src/AnimatedData.js#L42

@lelandrichardson
Copy link
Contributor Author

@gre can you weigh in on this PR? I'm curious if this would solve your use case. #12

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

4 participants