Skip to content

Commit

Permalink
Updated README;
Browse files Browse the repository at this point in the history
  • Loading branch information
DigitalBrainJS committed Apr 26, 2021
1 parent 71282be commit 9c04744
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,31 @@ If this argument not specified or null, the internal default AbortController wil

### @cancel([reason: String], [signal: AbortSignal|String|Symbol])
Emits the cancel signal before the target function invoking.
It can be called as a function, passing the context using `.call` or `.apply`.

````javascript
class Klass{
@canceled(()=> console.log(`canceled`))
@listen('internalControllerId')
*bar(){
yield CPromise.delay(1000);
console.log('done!');
}

@cancel('E_SOME_REASON', 'internalControllerId')
*baz(){

}
}
const instance= new Klass;

instance.bar().then(console.log, console.warn);

// cancel bar execution
cancel.call(intance, E_SOME_REASON, 'internalControllerId');
// calling `baz` will terminate the `bar` execution as well
instance.baz();
````

### @canceled([onRejected(err, scope, context): Function])
Catches rejections with CanceledError errors
Expand Down Expand Up @@ -917,6 +942,16 @@ Sets the innerWeight option for the CPromise async function.
### @label(label: String)
Sets the label option for the CPromise async function.

### @atomic([atomicType: 'disabled'|'detached'|'await'|true|false])
Configures decorated CPromise async function as atomic.

### ReactComponent([{subscribeAll?: boolean}])
Decorates class as React component:
- decorates all generator to `CPromise` async function;
- subscribes `componentDidMount` method to the internal `AbortController` signal of the class
- decorates `componentWillUnmount` with `@cancel` decorator
to invoke `AbortController.abort()` before running the method;

## Events
All events (system and user defined) can be fired only when promises in pending state.

Expand Down
35 changes: 35 additions & 0 deletions jsdoc2md/README.hbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,31 @@ If this argument not specified or null, the internal default AbortController wil

### @cancel([reason: String], [signal: AbortSignal|String|Symbol])
Emits the cancel signal before the target function invoking.
It can be called as a function, passing the context using `.call` or `.apply`.

````javascript
class Klass{
@canceled(()=> console.log(`canceled`))
@listen('internalControllerId')
*bar(){
yield CPromise.delay(1000);
console.log('done!');
}

@cancel('E_SOME_REASON', 'internalControllerId')
*baz(){

}
}
const instance= new Klass;

instance.bar().then(console.log, console.warn);

// cancel bar execution
cancel.call(intance, E_SOME_REASON, 'internalControllerId');
// calling `baz` will terminate the `bar` execution as well
instance.baz();
````

### @canceled([onRejected(err, scope, context): Function])
Catches rejections with CanceledError errors
Expand Down Expand Up @@ -917,6 +942,16 @@ Sets the innerWeight option for the CPromise async function.
### @label(label: String)
Sets the label option for the CPromise async function.

### @atomic([atomicType: 'disabled'|'detached'|'await'|true|false])
Configures decorated CPromise async function as atomic.

### ReactComponent([{subscribeAll?: boolean}])
Decorates class as React component:
- decorates all generator to `CPromise` async function;
- subscribes `componentDidMount` method to the internal `AbortController` signal of the class
- decorates `componentWillUnmount` with `@cancel` decorator
to invoke `AbortController.abort()` before running the method;

## Events
All events (system and user defined) can be fired only when promises in pending state.

Expand Down

0 comments on commit 9c04744

Please sign in to comment.