FCF 2.0 development in progress...
> > > >
[News] [Packages API] [Downloads] [Donate to the project] [Contacts]

fcf.Actions class

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

The class of asynchronous operations is similar to Promise and can be used with the await operator, but has slightly different functionality.

Detailed description

The main distinguishing feature is that the class fcf.Actions is a run queue, where each call to then can add a function with confirmation completion of the operation.

let actions = new fcf.Actions(); await actions.then((a_result, a_act)=>{ setTimeout(()=>{ console.log("Step 001"); a_act.complete("Hello world"); }, 1000); }) .then((a_result)=>{ console.log("Step 002:", a_result); });

Output:

Step 001 Step 002: Hello world

Methods
constructor(object a_options)
constructor(function a_cb, object a_options)
- Constructor
fcf.Actions then(function a_cb, function a_cberror = undefined)
- Adds a handler function to the processing queue
fcf.Actions each(object|array|function a_obj, function a_cb)
- Iterates over the passed object, calling a separate a_cb handler for each element of the object, which is added to the shared task queue. The iterable object can be passed to a function that returns the iterable object. In this case, the object acquisition will be performed immediately before the handler function is executed.
fcf.Actions asyncEach(object|array|function a_obj, function a_cb)
- Iterates over the passed object, calling a separate a_cb handler for each element of the object, the handlers for the passed set being executed simultaneously asynchronously. The iterable object can be passed to a function that returns the iterable object. In this case, the object acquisition will be performed immediately before the handler function is executed.
fcf.Actions catch(function a_cb)
- Adds an error handler that is called when an exception occurs or the fcf.Actions.Act.error() method is called in a deferred action.
fcf.Actions finally(function a_cb)
- Adds a callback to the run queue that is also called will be called on error
fcf.Actions startup()
- Changes the fcf.Actions object from the pending state to the running state. To use a method, the deferred flag must be set on the object.
Error error()
fcf.Actions error(Error a_error)
- Gets or sets the error in the fcf.Actions object, depending on the arguments passed.
mixed result()
fcf.Actions result(mixed a_value)
- Gets or sets the result of executing an object depending on the arguments passed
fcf.Actions exception()
- Throws an exception if the object of actions is in a state of error
fcf.Actions options({deferred, noexcept, errorResult, quiet} a_options)
{deferred, noexcept, errorResult, quiet} options()
- Sets or gets the parameters of the pending action object, depending on the parameters passed.
Promise promise()
- Returns the Promise object queued for execution