-
Notifications
You must be signed in to change notification settings - Fork 8
ofClass
richardszalay edited this page May 20, 2011
·
5 revisions
Filters out values that are not instances of a certain type (or a sub-class of that type)
function ofClass(valueClass : Class) : IObservable.<valueClass>
As values are emitted from the source, they are checked to be instances of valueClass. If the value is an instance of valueClass or a subclass, the value is emitted; otherwise, the value is skipped.
The returned sequence completes when the source sequence completes.
The returned sequence errors when the source sequences errors.
xs = source
ys = output
true = value is instance of 'type'
false = value is not an instance of 'type'
xs ──o─────o─────o─────o────/
│ │ │ │ │
true false false true │
│ │ │
ys ──o─────────────────o────/
IObservable.<valueClass>
var source : IObservable = toObservable(
["first", 0, 1, 2, "second", "third"])
.ofType(String);
source.subscribe(function(value : Object) : void
{
trace(value);
});
// Trace output is:
// first
// second
// third