Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation on transaction behavior #28

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ This makes your app feel super fast, regardless of server location or internet c
| FSA compliant | not FSA compliant |
| must wrap your state calls in `ensureState` | no change necessary to get your state |

## How do optimistic actions work?

- When you dispatch a `BEGIN` action:
- The action is dispatched normally.
- Your reducer should update your state with the expected outcome of the optimistic action and can optionally indicate that the change is "pending" (e.g. not fully loaded).
- When you dispatch a `COMMIT` action:
- The action is dispatched normally.
- Your reducer should clear the "pending" flag, if you used it.
- When you dispatch a `REVERT` action:
- The state is reverted to its value before the `BEGIN` action.
- All actions after the `BEGIN` that have been previously dispatched are re-dispatched immediately (this makes it look as though the initial `BEGIN` action never happened).
- The `REVERT` action is dispatched normally.
- Your reducer should update the state to indicate the error message to the user and clear the "pending" flag, if you used it.

## Usage

### Feed it your reducer
Expand Down