|  | @@ -1,3 +1,44 @@
 | 
	
		
			
				|  |  |  # redux-sac
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -Slice and compose redux-type reducers.
 | 
	
		
			
				|  |  | +Slice and compose redux-type reducers.
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +## `subReducer(key, reducer, additionalKey, ...)`
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +Creates a wrapper reducer that call `reducer`
 | 
	
		
			
				|  |  | +on the substate specified by `key`.
 | 
	
		
			
				|  |  | +You may use dot notation.
 | 
	
		
			
				|  |  | +Rest of the state is left untouched.
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +```js
 | 
	
		
			
				|  |  | +	const r = subReducer("persons", personReducer);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    r({persons: ["John", "Jill"], cars: ["Honda"]}, action);
 | 
	
		
			
				|  |  | +    // => {
 | 
	
		
			
				|  |  | +    //   persons: personReducer(["John", "Jill"], action), 
 | 
	
		
			
				|  |  | +    //   cars: ["Honda"]
 | 
	
		
			
				|  |  | +    // }
 | 
	
		
			
				|  |  | +```
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +Respects redux convention that if no change was made,
 | 
	
		
			
				|  |  | +the identical object should be returned. So in previous case,
 | 
	
		
			
				|  |  | +if `personReducer` would return the identical array,
 | 
	
		
			
				|  |  | +`r` would return the state object it was passed in.
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +If persons were deeper in hierarchy, it could have been created as
 | 
	
		
			
				|  |  | +`const r = subReducer("files.persons", personReducer);` for example.
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +You may pass additional keys (also with possible dot-notation)
 | 
	
		
			
				|  |  | +as addition arguments. In that case, additional parts of state
 | 
	
		
			
				|  |  | +will be fetched and passed to a sub-reducer:
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +```js
 | 
	
		
			
				|  |  | +	const r = subReducer("persons", personReducer, "assets.cars");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    r({persons: ["John", "Jill"], assets: {cars: ["Honda"]}}, action);
 | 
	
		
			
				|  |  | +    // => {
 | 
	
		
			
				|  |  | +    //   persons: personReducer(["John", "Jill"], action, ["Honda"]), 
 | 
	
		
			
				|  |  | +    //   assets: {cars: ["Honda"]}
 | 
	
		
			
				|  |  | +    // }
 | 
	
		
			
				|  |  | +```
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +This technique is mentioned in Redux docs, in "Beyond combineReducers" page.
 |