-
Notifications
You must be signed in to change notification settings - Fork 8
start
richardszalay edited this page May 20, 2011
·
7 revisions
Converts a function into an observable sequence
static function start(action : Function, scheduler : IScheduler = null) : IObservable.<TResult>
Where action is function() : TResult
start can be thought of as a callLater equivalent. It is similar to toAsync, but as it accepts no argument the returned sequence can be subscribed to immediately (without calling a function first).
Subscribing to the returned sequence calls the original action and emits the return value of the function as a value and then completes.
If action returns void, the value null will be emitted to the subscriber when the action executes.
Unless specified, Scheduler.asynchronous
will be used to schedule the call to action.
IObservable.<TResult>
var asyncAction : Function = Obervable.start(function() : int
{
return 500;
})
.subscribe(
function(value : String) : void { trace(value); },
function():void { trace("Completed"); }
);
// Trace output is:
// (After the next frame)
// 500
// Completed