Update readme.md
This commit is contained in:
parent
e779551291
commit
231fd8bd53
118
readme.md
118
readme.md
|
@ -25,8 +25,8 @@ To use redux-scc you need to be aware of two things: The buildStoreChunk() funct
|
||||||
##### buildStoreChunk
|
##### buildStoreChunk
|
||||||
```
|
```
|
||||||
buildStoreChunk(name: string, structure: ReducerType | {}, options: {
|
buildStoreChunk(name: string, structure: ReducerType | {}, options: {
|
||||||
baseSelector: Selector = state => state[name],
|
baseSelector: Selector = state => state[name],
|
||||||
locationString: string = name
|
locationString: string = name
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
buildStoreChunk takes a name and a structure (more on that later) and will return an object with the properties reducers, actions, and selectors.
|
buildStoreChunk takes a name and a structure (more on that later) and will return an object with the properties reducers, actions, and selectors.
|
||||||
|
@ -88,8 +88,8 @@ Here, we're just going to create a very basic store chunk that is one, solitary,
|
||||||
|
|
||||||
```
|
```
|
||||||
const exampleStoreChunk = buildStoreChunk('example', Types.reducer(Types.shape({
|
const exampleStoreChunk = buildStoreChunk('example', Types.reducer(Types.shape({
|
||||||
foo: Types.string(),
|
foo: Types.string(),
|
||||||
bar: Types.number(),
|
bar: Types.number(),
|
||||||
})));
|
})));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -97,15 +97,15 @@ This will return the following object:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
reducers: {
|
reducers: {
|
||||||
example: [Function: combination]
|
example: [Function: combination]
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
update: [Function: update] ,
|
update: [Function: update] ,
|
||||||
reset: [Function: reset],
|
reset: [Function: reset],
|
||||||
replace: [Function: replace],
|
replace: [Function: replace],
|
||||||
},
|
},
|
||||||
selectors: [Function]
|
selectors: [Function]
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -125,31 +125,31 @@ This produces the following object:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
reducers: {
|
reducers: {
|
||||||
screen,
|
screen,
|
||||||
users,
|
users,
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
screen: {
|
screen: {
|
||||||
reset,
|
reset,
|
||||||
replace,
|
replace,
|
||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
replaceAtIndex,
|
replaceAtIndex,
|
||||||
resetAtIndex,
|
resetAtIndex,
|
||||||
removeAtIndex,
|
removeAtIndex,
|
||||||
replace,
|
replace,
|
||||||
reset,
|
reset,
|
||||||
pop,
|
pop,
|
||||||
push,
|
push,
|
||||||
shift,
|
shift,
|
||||||
unshift,
|
unshift,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectors: {
|
selectors: {
|
||||||
screen,
|
screen,
|
||||||
users,
|
users,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -158,11 +158,11 @@ This produces the following object:
|
||||||
Above we saw how combined reducers would operate, here's a quick example of what a reducer nested inside another reducer would look like:
|
Above we saw how combined reducers would operate, here's a quick example of what a reducer nested inside another reducer would look like:
|
||||||
|
|
||||||
```
|
```
|
||||||
const exampleStoreChunk2 = buildStoreChunk('example2', {
|
const exampleStoreChunk2 = buildStoreChunk('example2', {
|
||||||
screen: Types.reducer({
|
screen: Types.reducer({
|
||||||
someNestedReducer: Types.reducer(Types.string()),
|
someNestedReducer: Types.reducer(Types.string()),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -170,22 +170,22 @@ Producing:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
reducers: {
|
reducers: {
|
||||||
screen, //Contains the combination of all child reducers
|
screen, //Contains the combination of all child reducers
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
screen: {
|
screen: {
|
||||||
someNestedReducer: {
|
someNestedReducer: {
|
||||||
reset,
|
reset,
|
||||||
replace,
|
replace,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectors: {
|
selectors: {
|
||||||
screen: {
|
screen: {
|
||||||
someNestedReducer,
|
someNestedReducer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue