Closed beckyconning closed 10 years ago
Sure, you can do this using the instanceof
operator. All three base classes are exposed as Kefir.Observable
, Kefir.Stream
, and Kefir.Property
.
Here is an example:
var x = Kefir.constant(1);
var y = Kefir.never();
x instanceof Kefir.Stream // false
y instanceof Kefir.Stream // true
x instanceof Kefir.Property // true
y instanceof Kefir.Property // false
x instanceof Kefir.Observable // true
y instanceof Kefir.Observable // true
Thanks, I changed the way tests are loaded so our app and tests both share the same instance of Kefir so that I could use this approach.
Ah, I didn't realize you need it to work with different instances of Kefir. Yeah, using the same instance is preferable solution here. I am glad it worked out :)
Is there a way to do something like the following?
If this worked regardless of which instance of Kefir the stream of property comes from I think that would be really useful for testing.
What I am doing at the moment is testing the
.__proto__._name
of the stream and or property.