Redux-like library for Google Apps Scripts
cd dist
git submodule add https://github.com/Glajik/gs-redux.git
If you don't have it, create it in the same folder where is .clasp.json
file.
Example of .claspignore
file
# Ignore all submodule's folders, except '*.js'
gs-redux/**
!gs-redux/*.js
// Describe reducer, that describe state calculation
const reducer = (state = 0, action) => {
switch (action.type) {
case 'INCREMENT':
return state + 1;
case 'DECREMENT':
return state - 1;
default:
return state;
}
};
// Create store
const store = createStore(reducer);
// Dispatch action
store.dispatch({ type: 'INCREMENT' });
// Get state
store.getState(); // 1
// See more usage examples in file __tests__/redux.test.js
From your root of project run
git submodule update --remote