Pausable synchronous executions. Fibers must be idempotent because its may be restarted for continuation.
[Unstable]
Starts sync function in new fiber. Returns Promise
.
const result_promise = $mol_fiber2.async( ()=> {
return fibered_fetch_json( '/profile' ).user_name
} )
Starts async function and waits it completition.
const result_promise = $mol_fiber2.async( ()=> {
const response = $mol_fiber2.wait( ()=> fetch( '/profile' ) )
const json = $mol_fiber2.wait( ()=> response.json() )
return json.user_name
} )
Converts unindempotent function to idempotent.
const log = $mol_fiber2.func( console.log )
$mol_fiber2.async( ()=> {
log( 'Started' )
log( fibered_fetch_json( '/profile' ) )
log( 'Finished' )
} )