Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit d3ab940

Browse files
Updated documentation
1 parent 7d93687 commit d3ab940

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,6 @@ openupm add nl.elraccoone.promises
5151

5252
# Documentation
5353

54-
## Syntax
55-
56-
```cs
57-
new Promise ((resolve, reject) => { /* ... */ });
58-
new Promise<ResolveType> ((resolve, reject) => { /* ... */ });
59-
new Promise<ResolveType, RejectType> ((resolve, reject) => { /* ... */ });
60-
```
61-
62-
A function that is passed with the arguments resolve and reject. The executor function is executed immediately by the Promise implementation, passing resolve and reject functions (the executor is called before the Promise constructor even returns the created object). The resolve and reject functions, when called, resolve or reject the promise, respectively. The executor normally initiates some asynchronous work, and then, once that completes, either calls the resolve function to resolve the promise or else rejects it if an error occurred. If an error is thrown in the executor function, the promise is rejected. The return value of the executor is ignored.
63-
64-
## Description
65-
6654
A Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous methods: instead of immediately returning the final value, the asynchronous method returns a promise to supply the value at some point in the future.
6755

6856
A Promise is in one of these states:
@@ -73,6 +61,16 @@ A Promise is in one of these states:
7361

7462
A pending promise can either be fulfilled with a value, or rejected with a reason (error). When either of these options happens, the associated handlers queued up by a promise's then method are called. (If the promise has already been fulfilled or rejected when a corresponding handler is attached, the handler will be called, so there is no race condition between an asynchronous operation completing and its handlers being attached.)
7563

64+
## Syntax
65+
66+
A function that is passed with the arguments resolve and reject. The executor function is executed immediately by the Promise implementation, passing resolve and reject functions (the executor is called before the Promise constructor even returns the created object). The resolve and reject functions, when called, resolve or reject the promise, respectively. The executor normally initiates some asynchronous work, and then, once that completes, either calls the resolve function to resolve the promise or else rejects it if an error occurred. If an error is thrown in the executor function, the promise is rejected. The return value of the executor is ignored.
67+
68+
```cs
69+
new Promise ((resolve, reject) => { /* ... */ });
70+
new Promise<ResolveType> ((resolve, reject) => { /* ... */ });
71+
new Promise<ResolveType, RejectType> ((resolve, reject) => { /* ... */ });
72+
```
73+
7674
## Creating a Promise
7775

7876
A Promise object is created using the new keyword and its constructor. This constructor takes as its argument a function, called the "executor function". This function should take two functions as parameters. The first of these functions (resolve) is called when the asynchronous task completes successfully and returns the results of the task as a value. The second (reject) is called when the task fails, and returns the reason for failure, which is typically an error object.

0 commit comments

Comments
 (0)