A Task makes it easy to model asynchronous operations that may fail, like HTTP requests or reading/writing to a files/databases
Task constructor
Param | Type | Description |
---|---|---|
f | function |
A function that takes two arguments reject and resolve, which in turn are functions. Function f normally initiates an asynchronous work or one that has effects, and then, once it completes, either calls the resolve function to resolve the Task or else rejects it. |
Task constructor that creates a Task which immediately resolves
Param | Type | Description |
---|---|---|
v | any |
value that is passed to the resolve function |
Task constructor that creates a Task which immediately gets rejected
Param | Type | Description |
---|---|---|
v | any |
value that is passed to the rejected function |
Executes the Task
Param | Type | Description |
---|---|---|
reject | function |
Function to be called when the Task is rejected |
resolve | function |
Function to be called when the Task is resolved |
Get a stringified version of the Task
Apply the function f to value of a successfully resolved Task
Param | Type | Description |
---|---|---|
f | function |
Function |
Get the function within the Task
Applys the successful value of the Task t to the successful value(a function) of the current Task
Param | Type | Description |
---|---|---|
t | Task |
Task with function as the second element |
Concat the current Task with the passed one and get a new Task. Which when resloved would get the successfull result of both the tasks.
Param | Type | Description |
---|---|---|
t | Task |
Task to concat |
Chain together many computations that return a Task
Param | Type | Description |
---|---|---|
f | function |
Function that returns another Task |
Converts the current task to a Promise