123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>JSDoc: Source: project/state.js</title>
- <script src="scripts/prettify/prettify.js"> </script>
- <script src="scripts/prettify/lang-css.js"> </script>
- <!--[if lt IE 9]>
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
- <![endif]-->
- <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
- <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
- </head>
- <body>
- <div id="main">
- <h1 class="page-title">Source: project/state.js</h1>
-
-
- <section>
- <article>
- <pre class="prettyprint source linenums"><code>/** @module project/state */
- /**
- * state.js
- *
- * Collection of everything which has to do with state changes.
- * - actionTypes
- * - actions
- **/
- import { NAME } from './constants'
- // import { call, put, takeEvery } from 'redux-saga/effects'
- /** actionTypes define what actions are handeled by the reducer. */
- export const actionTypes = {
- CREATE_REQ: `${NAME}/CREATE_REQ`,
- UPDATE_REQ: `${NAME}/UPDATE_REQ`,
- DELETE_REQ: `${NAME}/DELETE_REQ`
- }
- /** actions is an object with references to all action creators */
- function createProject (project) {
- return {
- type: actionTypes.CREATE_REQ,
- project
- }
- }
- function updateProject (projectId, project) {
- return {
- type: actionTypes.UPDATE_REQ,
- projectId,
- project
- }
- }
- function removeProject (projectId) {
- return {
- type: actionTypes.REMOVE_REQ,
- projectId
- }
- }
- export const actions = { createProject, updateProject, removeProject }
- /** state definition */
- export const state = []
- /** reducer is called by the redux dispatcher and handles all component actions */
- export function reducer (state = {}, action) {
- switch (action.type) {
- case actionTypes.CREATE:
- return {
- ...state,
- [action.project.projectId]: action.project
- }
- case actionTypes.UPDATE:
- return {
- ...state,
- [action.projectId]: action.project
- }
- case actionTypes.REMOVE:
- return {
- ...state,
- [action.projectId]: null
- }
- default:
- return state
- }
- }
- /** sagas are asynchronous workers (JS generators) to handle the state.
- // Worker
- export function * incrementAsync () {
- try {
- const data = yield call(Api.isIncrementOk)
- yield put({ type: 'INCREMENT_SUCCESS', data })
- } catch (error) {
- yield put({ type: 'INCREMENT_FAIL', error})
- }
- }
- // Watcher (intercepts INCREMENT_REQUEST, dispatches INCREMENT_SUCCESS or INCREMENT_FAIL in return.)
- export function * watchIncrementAsync () {
- yield takeEvery('INCREMENT_REQUEST', incrementAsync)
- }
- // export all sagas in parallel
- function * sagas () {
- yield takeEvery('INCREMENT_REQUEST')
- yield takeEvery('DECREMENT_REQUEST')
- } */
- export const sagas = null
- </code></pre>
- </article>
- </section>
- </div>
- <nav>
- <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-AutoMate.html">AutoMate</a></li><li><a href="module-demo_module.html">demo_module</a></li><li><a href="module-demo_module_components_index.html">demo_module/components/index</a></li><li><a href="module-demo_module_constants.html">demo_module/constants</a></li><li><a href="module-demo_module_initialData.html">demo_module/initialData</a></li><li><a href="module-demo_module_state.html">demo_module/state</a></li><li><a href="module-project.html">project</a></li><li><a href="module-project_components.html">project/components</a></li><li><a href="module-project_state.html">project/state</a></li><li><a href="module-registermap.html">registermap</a></li></ul>
- </nav>
- <br class="clear">
- <footer>
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Tue Mar 14 2017 18:34:23 GMT+0100 (W. Europe Standard Time)
- </footer>
- <script> prettyPrint(); </script>
- <script src="scripts/linenumber.js"> </script>
- </body>
- </html>
|