-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Job | ||
|
||
A job is a | ||
|
||
## API | ||
|
||
### Properties | ||
|
||
- `value` - The result of a successful Task execution. | ||
- `error` - The reason why a Task execution was unsuccessful. | ||
- `status` - The current status of the Task. Can be: `idle`, `pending`, `fulfilled`, `rejected`, or `aborted`. | ||
- `isIdle` - A boolean indicating whether the Task is idle. | ||
- `isPending` - A boolean indicating whether the Task is pending. | ||
- `isFulfilled` - A boolean indicating whether the Task was successful. | ||
- `isRejected` - A boolean indicating whether the Task was unsuccessful. | ||
- `isSettled` - A boolean indicating whether the Task has completed (fulfilled or rejected). | ||
- `isAborted` - A boolean indicating whether the Task was cancelled. | ||
- `signal` - An AbortSignal object for interpolation with signal-supported solution. | ||
|
||
### Methods | ||
|
||
- `perform()` - Starts execution of the Task. | ||
- `abort(cancelReason)` - Aborts the Task with an optional cancel reason. | ||
- `then(onFulfilled, onRejected)` - Registers callbacks to be called when the Task is fulfilled or rejected. | ||
- `catch(onRejected)` - Registers a callback to be called when the Task is rejected. | ||
- `finally(onFinally)` - Registers a callback to be called when the Task is settled. | ||
- `addEventListener(type, listener, options)` - Registers an event listener for Task events. | ||
- `removeEventListener(type, listener, options)` - Removes an event listener for Task events. | ||
|
||
### Events | ||
|
||
- `fulfill` - Triggered when the Task is fulfilled. | ||
- `reject` - Triggered when the Task is rejected. | ||
- `abort` - Triggered when the Task is cancelled. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Task | ||
|
||
A Task represents an asynchronous computation. It is a wrapper around a Promise that provides additional functionality and events. It can be performed only once and it manages the state of the promise. The task has built-in cancellation mechanism. | ||
|
||
## API | ||
|
||
### Construction | ||
|
||
```ts | ||
import { createTask } from 'solid-tasks'; | ||
|
||
const task = createTask(async (signal) => { | ||
const response = await fetch('...', { signal }) | ||
return response.json(); | ||
}); | ||
``` | ||
|
||
### Properties | ||
|
||
- `value` - The result of a successful Task execution. | ||
- `error` - The reason why a Task execution was unsuccessful. | ||
- `status` - The current status of the Task. Can be: `idle`, `pending`, `fulfilled`, `rejected`, or `aborted`. | ||
- `isIdle` - A boolean indicating whether the Task is idle. | ||
- `isPending` - A boolean indicating whether the Task is pending. | ||
- `isFulfilled` - A boolean indicating whether the Task was successful. | ||
- `isRejected` - A boolean indicating whether the Task was unsuccessful. | ||
- `isSettled` - A boolean indicating whether the Task has completed (fulfilled or rejected). | ||
- `isAborted` - A boolean indicating whether the Task was cancelled. | ||
- `signal` - An AbortSignal object for interpolation with signal-supported solution. | ||
|
||
### Methods | ||
|
||
- `perform()` - Starts execution of the Task. | ||
- `abort(cancelReason)` - Aborts the Task with an optional cancel reason. | ||
- `then(onFulfilled, onRejected)` - Registers callbacks to be called when the Task is fulfilled or rejected. | ||
- `catch(onRejected)` - Registers a callback to be called when the Task is rejected. | ||
- `finally(onFinally)` - Registers a callback to be called when the Task is settled. | ||
- `addEventListener(type, listener, options)` - Registers an event listener for Task events. | ||
- `removeEventListener(type, listener, options)` - Removes an event listener for Task events. | ||
|
||
### Events | ||
|
||
- `fulfill` - Triggered when the Task is fulfilled. | ||
- `reject` - Triggered when the Task is rejected. | ||
- `abort` - Triggered when the Task is cancelled. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.