12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- /** @module setting/state */
- /**
- * state.js
- *
- * Collection of everything which has to do with state changes.
- **/
- /** actionTypes define what actions are handeled by the reducer. */
- export const actions = {
- changePriceAdult: priceAdult => {
- return {
- type: 'SETTING_CHANGE_PRICE_ADULT',
- priceAdult
- }
- },
- changePriceJunior: priceJunior => {
- return {
- type: 'SETTING_CHANGE_PRICE_JUNIOR',
- priceJunior
- }
- }
- }
- console.log('State actions', actions)
- /** state definition */
- export const state = {
- priceAdult: 50,
- priceJunior: 30
- }
- console.log('State state', state)
- /** reducer is called by the redux dispatcher and handles all component actions */
- export function reducer (state = [], action) {
- switch (action.type) {
- case 'SETTING_CHANGE_PRICE_ADULT':
- return { ...state, priceAdult: action.priceAdult }
- case 'SETTING_CHANGE_PRICE_JUNIOR':
- return { ...state, priceJunior: action.priceJunior }
- default:
- return state
- }
- }
- /** sagas are asynchronous workers (JS generators) to handle the state. */
- export function * saga () {}
|