Skip to content

Commit 670e512

Browse files
authored
Merge pull request #1021 from thefrontside/tm/rename-actions-page
2 parents 306002d + b3b629a commit 670e512

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

docs/actions.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
In this section, we'll cover one of the most fundamental operations in
2-
Effection: `action()`, and how we can use it as a safe alternative to
1+
In this section, we'll cover how we can use `action` as a safe alternative to
32
the [Promise constructor][promise-constructor].
43

54
## Example: Sleep
65

76
Let's revisit our sleep operation from the [introduction to
8-
operations](./operations):
9-
7+
operations](../operations):
108

119
```js
1210
export function sleep(duration: number): Operation<void> {
@@ -58,7 +56,8 @@ an abort signal was there without sacrificing any clarity in achieving it.
5856

5957
## Action Constructor
6058

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
6261
[promise constructor][promise-constructor]. To see this, let's
6362
use [one of the examples from MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise#examples)
6463
that uses promises to make a crude replica of the global [`fetch()`][fetch]
@@ -90,7 +89,7 @@ function* fetch(url) {
9089
xhr.onload = () => resolve(xhr.responseText);
9190
xhr.onerror = () => reject(xhr.statusText);
9291
xhr.send();
93-
return () => { } // "finally" function place holder.
92+
return () => {}; // "finally" function place holder.
9493
});
9594
}
9695
```
@@ -109,11 +108,11 @@ until _both_ requests are have received a response.
109108
```js
110109
await Promise.race([
111110
fetch("https://openweathermap.org"),
112-
fetch("https://open-meteo.org")
113-
])
111+
fetch("https://open-meteo.org"),
112+
]);
114113
```
115114

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
117116
make sure that the request is cancelled when it is either resolved, rejected, or
118117
passes out of scope.
119118

@@ -125,15 +124,16 @@ function* fetch(url) {
125124
xhr.onload = () => resolve(xhr.responseText);
126125
xhr.onerror = () => reject(xhr.statusText);
127126
xhr.send();
128-
return () => { xhr.abort(); }; // called in all cases
127+
return () => {
128+
xhr.abort();
129+
}; // called in all cases
129130
});
130131
}
131132
```
132133

133-
>💡Almost every usage of the [promise concurrency primitives][promise-concurrency]
134+
> 💡Almost every usage of the [promise concurrency primitives][promise-concurrency]
134135
> will contain bugs born of leaked effects.
135136
136-
137137
[abort-signal]: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
138138
[fetch]: https://developer.mozilla.org/en-US/docs/Web/API/fetch
139139
[promise-constructor]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise

docs/installation.mdx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ If you encounter obstacles integrating with your environment, please create a [G
33

44
## Node.js & Browser
55

6-
<p class="inline-flex my-0 flex-wrap gap-1">
7-
<img class="my-1" src="https://badgen.net/bundlephobia/min/effection" alt="Bundlephobia badge showing effection minified" />
8-
<img class="my-1" src="https://badgen.net/bundlephobia/minzip/effection" alt="Bundlephobia badge showing effection gzipped size" />
9-
<img class="my-1" src="https://badgen.net/bundlephobia/tree-shaking/effection" alt="Bundlephobia badge showing it's treeshackable" />
10-
</p>
11-
126
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.
137

148
```bash
@@ -24,7 +18,7 @@ yarn add effection
2418
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:
2519

2620
```ts
27-
import { main } from "https://deno.land/x/effection/mod.ts";
21+
import { main } from "jsr:@effection/[email protected]";
2822
```
2923

3024
> 💡 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].

docs/structure.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
],
99
"Learn Effection": [
1010
["operations.mdx", "Operations"],
11-
["actions.mdx", "Actions and Suspensions"],
12-
["resources.mdx", "Resources"],
1311
["spawn.mdx", "Spawn"],
12+
["resources.mdx", "Resources"],
1413
["collections.mdx", "Streams and Subscriptions"],
1514
["events.mdx", "Events"],
1615
["errors.mdx", "Error Handling"],
17-
["context.mdx", "Context"]
16+
["context.mdx", "Context"],
17+
["actions.mdx", "Actions"]
1818
],
1919
"Advanced": [
2020
["faq.mdx", "FAQ"],

0 commit comments

Comments
 (0)