1. Getting Started
2. Basic Concepts
3. Handlers
4. Advanced Concepts
4.0.1 Creating Custom Reducer4.0.2 Modifying api end points reducer constants4.0.3 Don't reset on setting to initial state4.0.4 Cancelling Api Calls4.0.5 Axios Interceptors4.0.6 Inject saga and reducer to the store4.0.7 Inject saga and reducer to the store by using hooks4.0.8 Util Functions# Safe Function# Other Util functions4.0.9 PARAMS4.1.0 Handling Multiple tasks
Util Functions
# Safe Function
Note:-This function will be used for accessing deep level of object.
import { Safe } from 'react-boilerplate-redux-saga-hoc';Example 1:const defaultValue = '';const object = { name: { name: { age: { person: 'jfjj' } } } }const Person = Safe(object , '.name.name.age.person', defaultValue);Example 2:const callback = (person) => return person + person;const Person = Safe(object , '.name.name.age.person', defaultValue , callback)
Note:-defaultValue is typeof value should return ,if the value return array by default safe function will return default value.-if don't pass any value in third parameter it return the ececuted value otherwise return null.
# Other Util functions
import { cloneObject , newObject } from 'react-boilerplate-redux-saga-hoc';Example 1:const oldObject = { name: '' };const newObject = { age: '' };const obj = cloneObject(oldObject, newObject)obj returns { name: '', age: '' }Example 2:const object = { name: '',profile: { name : '' } };const obj = newObject(object,({ profile }) => ({profile: newObject(profile, { age: 20 })}))obj returns { name: '', age: 20 }
import {cloneObject,newObject,deleteIn,getIn,objectEquals,setIn,updateIn,generateTimeStamp,} from "react-boilerplate-redux-saga-hoc";const data = {};console.log(getIn(data, ["data", "age"])); // returns data or undefinedconst deletedData = deleteIn(data, ["data", "age"]); // returns dataconst newdata = setIn(data, ["data", "age"], 20);const updatedData = updateIn(data, ["data", "age"], () => 30);console.log(generateTimeStamp());console.log(objectEquals({}, {}));