123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- /** @module player/state */
- // import { call, put, takeEvery, takeLatest } from 'redux-saga/effects'
- /**
- * state.js
- *
- * Collection of everything which has to do with state changes.
- **/
- /** actionTypes define what actions are handeled by the reducer. */
- export const actions = {
- alertAdd: data => {
- console.log('adding alert', data)
- return {
- type: 'ALERT_ADD',
- data
- }
- },
- alertDismiss: alertId => {
- console.log('dismissing alert', alertId)
- return {
- type: 'ALERT_DISMISS',
- alertId
- }
- }
- }
- console.log('State actions', actions)
- /** state definition */
- export const state = {
- alerts: []
- }
- 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 'ALERT_ADD':
- return { ...state, alerts: [ ...state.alerts, action.data ] }
- case 'ALERT_DISMISS':
- return { ...state, alerts: [ ...state.alerts.slice(0, action.alertId), ...state.alerts.slice(action.alertId + 1) ] }
- default:
- return state
- }
- }
- /** sagas are asynchronous workers (JS generators) to handle the state. */
- export function * saga () {}
|