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

then() method from fcf.Actions class

fcf.Actions then(function a_cb, function a_cberror = undefined)

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Adds a handler function to the processing queue


function a_cb
- The handler function to be added to the task queue. The result returned by the function will be passed to the next handler.

A handler function can have two formats:

  • mixed a_cb(mixed a_lastResult) - Format without confirmation of completion of the operation. The function can be asynchronous. The execution of the next handler begins after the function has completed or the Promise or fcf.Actions object it returned has completed.

  • mixed a_cb(mixed a_lastResult, 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.

function a_cberror
- An error handler function that will be added to the list of functions to be called in case of an error. Passing this argument is the same as calling a methodfcf.Actions.catch

Function signature: a_cb(object a_error)

- Self pointer

Example: Function application

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


Step 001 Step 002: Hello world