project_state.js.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: project/state.js</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Source: project/state.js</h1>
  17. <section>
  18. <article>
  19. <pre class="prettyprint source linenums"><code>/** @module project/state */
  20. /**
  21. * state.js
  22. *
  23. * Collection of everything which has to do with state changes.
  24. * - actionTypes
  25. * - actions
  26. **/
  27. import { NAME } from './constants'
  28. // import { call, put, takeEvery } from 'redux-saga/effects'
  29. /** actionTypes define what actions are handeled by the reducer. */
  30. export const actionTypes = {
  31. CREATE_REQ: `${NAME}/CREATE_REQ`,
  32. UPDATE_REQ: `${NAME}/UPDATE_REQ`,
  33. DELETE_REQ: `${NAME}/DELETE_REQ`
  34. }
  35. /** actions is an object with references to all action creators */
  36. function createProject (project) {
  37. return {
  38. type: actionTypes.CREATE_REQ,
  39. project
  40. }
  41. }
  42. function updateProject (projectId, project) {
  43. return {
  44. type: actionTypes.UPDATE_REQ,
  45. projectId,
  46. project
  47. }
  48. }
  49. function removeProject (projectId) {
  50. return {
  51. type: actionTypes.REMOVE_REQ,
  52. projectId
  53. }
  54. }
  55. export const actions = { createProject, updateProject, removeProject }
  56. /** state definition */
  57. export const state = []
  58. /** reducer is called by the redux dispatcher and handles all component actions */
  59. export function reducer (state = {}, action) {
  60. switch (action.type) {
  61. case actionTypes.CREATE:
  62. return {
  63. ...state,
  64. [action.project.projectId]: action.project
  65. }
  66. case actionTypes.UPDATE:
  67. return {
  68. ...state,
  69. [action.projectId]: action.project
  70. }
  71. case actionTypes.REMOVE:
  72. return {
  73. ...state,
  74. [action.projectId]: null
  75. }
  76. default:
  77. return state
  78. }
  79. }
  80. /** sagas are asynchronous workers (JS generators) to handle the state.
  81. // Worker
  82. export function * incrementAsync () {
  83. try {
  84. const data = yield call(Api.isIncrementOk)
  85. yield put({ type: 'INCREMENT_SUCCESS', data })
  86. } catch (error) {
  87. yield put({ type: 'INCREMENT_FAIL', error})
  88. }
  89. }
  90. // Watcher (intercepts INCREMENT_REQUEST, dispatches INCREMENT_SUCCESS or INCREMENT_FAIL in return.)
  91. export function * watchIncrementAsync () {
  92. yield takeEvery('INCREMENT_REQUEST', incrementAsync)
  93. }
  94. // export all sagas in parallel
  95. function * sagas () {
  96. yield takeEvery('INCREMENT_REQUEST')
  97. yield takeEvery('DECREMENT_REQUEST')
  98. } */
  99. export const sagas = null
  100. </code></pre>
  101. </article>
  102. </section>
  103. </div>
  104. <nav>
  105. <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>
  106. </nav>
  107. <br class="clear">
  108. <footer>
  109. 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)
  110. </footer>
  111. <script> prettyPrint(); </script>
  112. <script src="scripts/linenumber.js"> </script>
  113. </body>
  114. </html>