-
Notifications
You must be signed in to change notification settings - Fork 16
/
reselect.node.txt
28 lines (21 loc) · 2.28 KB
/
reselect.node.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
RESELECT
VERSION ==> #2.3.4
#Reduce several functions with same arguments into a single one:
# - FUNC(ARGS)->VAL + FUNC2(ARGS)->VAL2 + ...
# -> REDUCE(VAL, VAL2, ...)->VAL0
# -> FUNC0(ARGS)->VAL0
#Alternative (structuredSelector):
# - FUNC(ARGS)->VAL + FUNC2(ARGS)->VAL2 + ...
# -> FUNC0(ARGS)->{ VAR: VAL, VAR2: VAL2 }
#Since FUNC0 has same arguments, it can be used in same places as FUNC[2]
#Often used in Flux, e.g. React-Redux: translating STORE state into components PROPS
SL_FUNC(SL_ARGS...)->SL_RET #"Selector" function.
#Must be pure because following methods memoize each call (using ===)
#(can customize memoization, see source code)
RESELECT.createSelector
(SL_FUNC...|SL_FUNC_ARR,
FUNC3(SL_RET...)->SL_RET2) #Returns SL_FUNC2(SL_ARGS...)->SL_RET2
RESELECT.createStructuredSelector
({ VAR: SL_FUNC ... }) #Returns SL_FUNC2(SL_ARGS...)->{ VAR: SL_RET ... }