Skip to content

Commit 0c03051

Browse files
authored
Update 02_createcustomoperators.md
1 parent 7075f7e commit 0c03051

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/overmind-website/guides/pro/02_createcustomoperators.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Create custom operators
22

3-
The operators of Overmind is based on the [op-op spec](https://github.com/christianalfoni/op-op-spec), which allows for endless possibilities in functional composition. But since Overmind does not only pass values through these operators, but also the context where you can change state, run effects etc., we want to simplify how you can create your own operators. The added benefit of this is that the operators you create are also tracked in the devtools.
3+
The operators concept of Overmind is based on the [op-op spec](https://github.com/christianalfoni/op-op-spec), which allows for endless possibilities in functional composition. But since Overmind does not only pass values through these operators, but also the context where you can change state, run effects etc., we want to simplify how you can create your own operators. The added benefit of this is that the operators you create are also tracked in the devtools.
44

55
## toUpperCase
66

@@ -10,21 +10,21 @@ Let us create an operator that simply uppercases the string value passed through
1010
h(Example, { name: "guide/createcustomoperators/touppercase" })
1111
```
1212

13-
We first create a function that returns an operator when we call it. We pass this operator a **name**, an optional **description** and the callback that is executed when the operator runs. This operator might receive an **error**, that you can handle if you want to. It also receives the **context**, the current **value** and function called **next**.
13+
We first create a function that returns an operator when we call it. We pass this operator a **name**, an optional **description** and the callback that is executed when the operator runs. This operator might receive an **error**, that you can handle if you want to. It also receives the **context**, the current **value** and a function called **next**.
1414

15-
In this example we did not use the **context** because we are not going to look at any state, run effects etc. We just wanted to change the value passed through. All operators needs to handle the **error** in some way. In this case we just pass it a long to the next operator by calling **next** with the error as the first argument and the current value as the second. When there is no error it means we can manage our value and we do so by calling **next** again, but passing **null** as the first argument, as there is no error. And the second argument is the new **value**.
15+
In this example we did not use the **context** because we are not going to look at any state, run effects etc. We just wanted to change the value passed through. All operators need to handle the **error** in some way. In this case we just pass it along to the next operator by calling **next** with the error as the first argument and the current value as the second. When there is no error it means we can manage our value and we do so by calling **next** again, but passing **null** as the first argument, as there is no error. And the second argument is the new **value**.
1616

1717
## operations
1818

19-
You might want to run some logic related to your operator. Typically this is done by giving a callback. You can provide this callback whatever information you want, even handle its return value. So for example the **map** operator is implemented likt his:
19+
You might want to run some logic related to your operator. Typically this is done by giving a callback. You can provide this callback whatever information you want, even handle its return value. So for example the **map** operator is implemented like this:
2020

2121
```marksy
2222
h(Example, { name: "guide/createcustomoperators/map" })
2323
```
2424

2525
## mutations
2626

27-
You can also create operators that has the ability to mutate the state, it is just a different factory **createMutationFactory**. This is how the **action** operator is implemented:
27+
You can also create operators that have the ability to mutate the state, it is just a different factory **createMutationFactory**. This is how the **action** operator is implemented:
2828

2929
```marksy
3030
h(Example, { name: "guide/createcustomoperators/action" })
@@ -40,10 +40,10 @@ h(Example, { name: "guide/createcustomoperators/when" })
4040

4141
## aborting
4242

43-
Some operators wants to prevent further execution. That is also possible to implement, as seen here with the **filter** operator:
43+
Some operators want to prevent further execution. That is also possible to implement, as seen here with the **filter** operator:
4444

4545
```marksy
4646
h(Example, { name: "guide/createcustomoperators/filter" })
4747
```
4848

49-
The **final** argument bypasses any other operators.
49+
The **final** argument bypasses any other operators.

0 commit comments

Comments
 (0)