From 6f1873de1628beaff110d8643d911d4af1e7c8b3 Mon Sep 17 00:00:00 2001 From: ymekuria Date: Mon, 24 Jun 2024 15:33:55 -0700 Subject: [PATCH] feat(actions-and-reducers.mdx): remove actionState from return of reduce --- .../writing-a-zkapp/feature-overview/actions-and-reducer.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zkapps/writing-a-zkapp/feature-overview/actions-and-reducer.mdx b/docs/zkapps/writing-a-zkapp/feature-overview/actions-and-reducer.mdx index e8202b331..3d7551b4c 100644 --- a/docs/zkapps/writing-a-zkapp/feature-overview/actions-and-reducer.mdx +++ b/docs/zkapps/writing-a-zkapp/feature-overview/actions-and-reducer.mdx @@ -88,7 +88,7 @@ let newState = this.reducer.reduce( The `acc` shown earlier is now `state`; you must pass in the state's type as a parameter and pass in an `actionState` which refers to one particular point in the action's history. -Like `Array.reduce`, `Reducer.reduce` takes a callback that has the signature `(state: S, action: A) => S`, where `S` is the `stateType` and `A` is the `actionType`. It returns the result of applying all the actions, in order, to the initial `state`. In this example, the returned `state` is `Bool(true)` because one of the actions in the list is `Field(1000)`. Reduce also returns the new actionState -- so you can store it to use when you reduce the next batch of actions. One last difference to JavaScript `reduce` is that it takes a _list of lists_ of actions, instead of a flat list. Each of the sublists are the actions that were dispatched in one account update (for example, while running one smart contract method). +Like `Array.reduce`, `Reducer.reduce` takes a callback that has the signature `(state: State, action: Action) => State`, where `State` is the `stateType` and `Action` is the `actionType`. It returns the result of applying all the actions, in order, to the initial `state`. In this example, the returned `state` is `Bool(true)` because one of the actions in the list is `Field(1000)`. One last difference to JavaScript `reduce` is that it takes a _list of lists_ of actions, instead of a flat list. Each of the sublists are the actions that were dispatched in one account update (for example, while running one smart contract method). As an astute reader, you might have noticed that this use of `state` is eerily similar to a standard "Elm architecture" that scans over an implicit infinite stream of actions (though here they are aggregated in chunks). This problem is familiar to web developers through its instantiation by using the Redux library or by using the `useReducer` hook in React.