Skip to content
This repository was archived by the owner on Feb 11, 2021. It is now read-only.

Commit e3e52a9

Browse files
committed
Add general text to README
1 parent 6a75325 commit e3e52a9

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,49 @@
11
# redux-trigger
2+
23
Redux State Triggers
4+
5+
## What is it?
6+
7+
redux-trigger is a Redux middleware which allows delayed dispatching of an action
8+
based on a trigger state in the Redux store. Here's how it works:
9+
10+
1. Dispatch a trigger (with action and state comparator function)
11+
2. The comparator function will be run every time the state is updated
12+
3. When the comparator function returns true, the trigger's action is dispatched
13+
14+
## Why do it this way?
15+
16+
There are many ways to handle asynchronous state changes within redux, just
17+
look at the related project list below. However, for many of these, promises are
18+
resolved at action dispatch time, or in the middlewares. This is okay for simple,
19+
discrete cases, but what about those cases where the same state can be reached
20+
in different ways?
21+
22+
Promise flow: A -> B, B -> C, C -> D
23+
24+
But what if B can be reached in another way? Then you have:
25+
26+
Alternative promise flow: X -> B, B -> C, C -> D
27+
28+
Now you have to duplicate the promise chain for each possibility.
29+
30+
One of the primary principles of Redux is that the (state is the single source
31+
of truth.) [https://github.com/rackt/redux/blob/master/docs/introduction/ThreePrinciples.md#single-source-of-truth]
32+
Why then, shouldn't we trigger our asynchronous state based on that
33+
single source of truth for the application?
34+
35+
redux-triggers allows you to set a trigger for a desired state, and then
36+
dispatch the action when the app's state it meets your desired criteria.
37+
38+
## Related Projects
39+
40+
[redux-thunk](https://github.com/gaearon/redux-thunk)
41+
[redux-promise](https://github.com/acdlite/redux-promise)
42+
[redux-rx](https://github.com/acdlite/redux-rx)
43+
[redux-effects](https://github.com/redux-effects/redux-effects)
44+
[redux-saga](https://github.com/yelouafi/redux-saga)
45+
[redux-watch](https://github.com/jprichardson/redux-watch)
46+
[redux-batched-subscribe](https://github.com/tappleby/redux-batched-subscribe)
47+
[redux-debounced](https://github.com/ryanseddon/redux-debounced)
48+
49+

0 commit comments

Comments
 (0)