pjs.fiber.runPromise()

This API is deprecated, starting in Profound.js 6. If running Profound.js 6 or higher, use async/await instead. See here for an example.

This API calls a Promise function in a top-down manner within a fiber.

Parameters


  • JavaScript promise object

Return Value


The data passed to the promise resolve function is returned.

Exception Handling


If the promise is rejected, an error is thrown.

Examples

Run readFile Promise in a fiber
const readFile = require('fs-readfile-promise');
var fileContent = pjs.fiber.runPromise(readFile('./myfile'));
Read 2 files asynchronously in parallel at the same time in a fiber
const readFile = require('fs-readfile-promise');
var contents = pjs.fiber.runPromise(Promise.all([
  readFile("./myfile1"),
  readFile("./myfile2")
]));
var file1Content = contents[0];
var file2Content = contents[1];

Video Tutorials