Class webdriver.promise.Frame_

code »

An execution frame within a webdriver.promise.ControlFlow. Each frame represents the execution context for either a webdriver.promise.Task_ or a callback on a webdriver.promise.Deferred.

Each frame may contain sub-frames. If child N is a sub-frame, then the items queued within it are given priority over child N+1.

Constructor

webdriver.promise.Frame_ ( flow )
Parameters
flow: !webdriver.promise.ControlFlow
The flow this instance belongs to.
Show:

Instance Methods

code »abort ( error )

Aborts the execution of this frame, cancelling all outstanding tasks scheduled within this frame.

Parameters
error: *
The error that triggered this abortion.

Adds a new node to this frame.

Parameters
node: !(webdriver.promise.Frame_|webdriver.promise.Task_)
The node to insert.

Marks all of the tasks that are descendants of this frame in the execution tree as cancelled. This is necessary for callbacks scheduled asynchronous. For example: var someResult; webdriver.promise.createFlow(function(flow) { someResult = flow.execute(function() {}); throw Error(); }).addErrback(function(err) { console.log('flow failed: ' + err); someResult.then(function() { console.log('task succeeded!'); }, function(err) { console.log('task failed! ' + err); }); }); // flow failed: Error: boom // task failed! CancelledTaskError: Task discarded due to a previous // task failure: Error: boom

Parameters
reason: string
The cancellation reason.

Signals that this frame has successfully finished executing.

Returns
This frame's parent, if any.
Returns
The task currently executing within this frame, if any.
Returns
The root of this frame's tree.
code »notify_ ( fn, opt_error )
Parameters
fn: ?(function(*)|function())
The function to notify.
opt_error: *=
Value to pass to the notified function, if any.

Removes a child from this frame.

Parameters
child: !(webdriver.promise.Frame_|webdriver.promise.Task_)
The child to remove.
code »setParent ( parent )
Parameters
parent: webdriver.promise.Frame_
This frame's new parent.
Parameters
task: webdriver.promise.Task_
The task currently executing within this frame, if any.
code »toString ( )string

Instance Properties

Whether this frame is currently locked. A locked frame represents an executed function that has scheduled all of its tasks.

Once a frame becomes locked, any new frames which are added as children represent interrupts (such as a webdriver.promise.Promise callback) whose tasks must be given priority over those already scheduled within this frame. For example:

   var flow = webdriver.promise.controlFlow();
   flow.execute('start here', goog.nullFunction).then(function() {
     flow.execute('this should execute 2nd', goog.nullFunction);
   });
   flow.execute('this should execute last', goog.nullFunction);
 
code »onAbort : ?function(*)

The function to notify if this frame is aborted with an error.

code »onComplete : ?function()

The function to notify if this frame executes without error.

The task currently being executed within this frame.