зеркало из https://github.com/microsoft/satcheljs.git
Remove orchestratorAction and all references to it (#109)
This commit is contained in:
Родитель
8e8498f65f
Коммит
7fe3e9c956
19
README.md
19
README.md
|
@ -125,10 +125,10 @@ orchestrator(requestAddTodo, async (actionMessage) => {
|
|||
};
|
||||
```
|
||||
|
||||
### mutatorAction and orchestratorAction
|
||||
### mutatorAction
|
||||
|
||||
In many cases a given action only needs to be handled by one mutator or orchestrator.
|
||||
Satchel provides these utility APIs which encapsulate action creation, dispatch, and handling in one simple function call.
|
||||
In many cases a given action only needs to be handled by one mutator.
|
||||
Satchel provides this utility API which encapsulates action creation, dispatch, and handling in one simple function call.
|
||||
|
||||
The `addTodo` mutator above could be implemented as follows:
|
||||
|
||||
|
@ -143,18 +143,7 @@ let addTodo = mutatorAction(
|
|||
});
|
||||
```
|
||||
|
||||
An orchestrator can be created similarly:
|
||||
|
||||
```typescript
|
||||
let requestAddTodo = orchestratorAction(
|
||||
'REQUEST_ADD_TODO',
|
||||
async function requestAddTodo(text: string) {
|
||||
await addTodoOnServer(actionMessage.text);
|
||||
addTodo(actionMessage.text);
|
||||
});
|
||||
```
|
||||
|
||||
This is a succinct and easy way to write mutators and orchestrators, but it comes with a restriction:
|
||||
This is a succinct and easy way to write mutators, but it comes with a restriction:
|
||||
the action creator is not exposed, so no *other* mutators or orchestrators can subscribe to it.
|
||||
If an action needs multiple handlers then it must use the full pattern with action creators and handlers implemented separately.
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ export { dispatch } from './dispatcher';
|
|||
export { default as mutator } from './mutator';
|
||||
import { default as orchestrator } from './orchestrator';
|
||||
export { default as getRootStore } from './getRootStore';
|
||||
export { mutatorAction, orchestratorAction } from './simpleSubscribers';
|
||||
export { mutatorAction } from './simpleSubscribers';
|
||||
export { useStrict };
|
||||
|
||||
// exporting an alias for orchestrator called "flow"
|
||||
|
|
|
@ -25,4 +25,3 @@ export function createSimpleSubscriber(decorator: Function) {
|
|||
}
|
||||
|
||||
export const mutatorAction = createSimpleSubscriber(mutator);
|
||||
export const orchestratorAction = createSimpleSubscriber(orchestrator);
|
||||
|
|
Загрузка…
Ссылка в новой задаче