You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -58,7 +56,8 @@ an abort signal was there without sacrificing any clarity in achieving it.
58
56
59
57
## Action Constructor
60
58
61
-
The [`action()`][action] function provides a callback based API to create Effection operations. You don't need it all that often, but when you do it functions almost exactly like the
59
+
The [`action()`][action] function provides a callback based API to create Effection operations.
60
+
You don't need it all that often, but when you do it functions almost exactly like the
62
61
[promise constructor][promise-constructor]. To see this, let's
63
62
use [one of the examples from MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise#examples)
64
63
that uses promises to make a crude replica of the global [`fetch()`][fetch]
@@ -90,7 +89,7 @@ function* fetch(url) {
90
89
xhr.onload= () =>resolve(xhr.responseText);
91
90
xhr.onerror= () =>reject(xhr.statusText);
92
91
xhr.send();
93
-
return () => { }// "finally" function place holder.
92
+
return () => {};// "finally" function place holder.
94
93
});
95
94
}
96
95
```
@@ -109,11 +108,11 @@ until _both_ requests are have received a response.
109
108
```js
110
109
awaitPromise.race([
111
110
fetch("https://openweathermap.org"),
112
-
fetch("https://open-meteo.org")
113
-
])
111
+
fetch("https://open-meteo.org"),
112
+
]);
114
113
```
115
114
116
-
With Effection, this is easily fixed by calling `abort()` in the finally function to
115
+
With Effection, this is easily fixed by calling `abort()` in the finally function to
117
116
make sure that the request is cancelled when it is either resolved, rejected, or
118
117
passes out of scope.
119
118
@@ -125,15 +124,16 @@ function* fetch(url) {
125
124
xhr.onload= () =>resolve(xhr.responseText);
126
125
xhr.onerror= () =>reject(xhr.statusText);
127
126
xhr.send();
128
-
return () => { xhr.abort(); }; // called in all cases
127
+
return () => {
128
+
xhr.abort();
129
+
}; // called in all cases
129
130
});
130
131
}
131
132
```
132
133
133
-
>💡Almost every usage of the [promise concurrency primitives][promise-concurrency]
134
+
>💡Almost every usage of the [promise concurrency primitives][promise-concurrency]
Effection is available on [NPM][npm], as well as derived registries such as [Yarn][yarn] and [UNPKG][unpkg]. It comes with TypeScript types and can be consumed as both ESM and CommonJS.
13
7
14
8
```bash
@@ -24,7 +18,7 @@ yarn add effection
24
18
Effection has first class support for Deno because it is developed with [Deno](https://deno.land). Releases are published to [https://deno.land/x/effection](https://deno.land/x/effection). For example, to import the `main()` function:
25
19
26
20
```ts
27
-
import { main } from"https://deno.land/x/effection/mod.ts";
> 💡 If you're curious how we keep NPM/YARN and Deno packages in-sync, you can [checkout the blog post on how publish Deno packages to NPM.][deno-npm-publish].
0 commit comments