25
Using Redux GET - PUSH
npm install redux-js;
or
yarn add redux-js;
import redux from redux-js";
Add your initial storage in the index of your project
redux.store({
environment:env,
storage_cache:[],
requests_executed:[],
path:'',
sessions:{},
authorize:{},
pag_count:10,
pag_position:'top',
list_type:'table'
});
redux.push('sessions', {username:jc, data:'example'});
redux.push('sessions', {username:jc, data:'example'}, true);
redux.get('sessions');
redux.get('sessions', true);
redux.remove('sessions');
redux.all();
useEffect(() => {
const unsubscribe = redux.subscribe( () => {
//Use 'is' or 'current'
//Using is return boolean
if(redux.is('sessions')){
console.log('It is my event');
}
//Using current return string
if(redux.current()==='sessions'){
console.log('It is my event');
}
});
return () => {
unsubscribe();
}
}, []);
componentDidMount = () => {
this.unsubscribe = redux.subscribe( () => {
//Use 'is' or 'current'
//Using is return boolean
if(redux.is('sessions')){
console.log('It is my event');
}
//Using current return string
if(redux.current()==='sessions'){
console.log('It is my event');
}
});
};
componentWillUnmount = () => {
this.unsubscribe();
};
25