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

constructor() method from fcf.Actions class

constructor(object a_options)
constructor(function a_cb, object a_options)

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Constructor

Arguments

{deferred, noexcept, errorResult} a_options
- Additional object initialization parameters
  • boolean deferred = false - If the flag is true, then the added callbacks will not be executed until the fcf.Actions.startup() method is called.

  • boolean noexcept = false - If the flag is true, then when the callback ends with an error, the queue is not stopped and the handlers passed to catch are not called.

  • mixed errorResult = undefined - The result returned by the result() method in case of an error

  • boolean quiet = false - If true, no raw error messages are printed to the console.

function a_cb
- The handler function that will be added to the task queue.

A handler function can have two formats:

  • mixed a_cb() - Format without confirmation of completion of the operation. The function can be asynchronous. The result returned by the function will be passed to the next handler.

    let actions = new fcf.Actions(()=>{ return "hello" }); actions.then((a_result)=>{ console.log(a_result); });

    Output:

    hello

  • mixed a_cb(fcf.Actions.Act a_act) - Format with confirmation of completion of the operation. To complete an asynchronous operation, the handler function must call the fcf.Actions.Act.complete() method or fcf.Actions.Act.error() on an error. The result passed to the fcf.Actions.Act.complete() function call will be passed to the next handler.

    let actions = new fcf.Actions((a_act)=>{ setTimeout(()=>{ a_act.complete("hello"); }, 1000) }); actions.then((a_result)=>{ console.log(a_result); });

    Output:

    hello