Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 1.14 KB

README.md

File metadata and controls

45 lines (32 loc) · 1.14 KB

Player State

Player Reducer and Selectors creating the state, created with redux-actions

Reducers

Each state slice provides a reducer function, that can be used to create the store:

import { combineReducers } from 'redux'

import { reducer as runtime } from '@podlove/player-state/runtime'
import { reducer as theme } from '@podlove/player-state/theme'

export default combineReducers({
  runtime,
  theme
})

Depending on the application use case only a specific set of reducers can be used and arbitrary combined.

Selectors

A selector is a function that provides access to a specific state property without the need to know the specific state structure:

import { selectors as runtime } from '@podlove/player-state/runtime'
import { createSelector } from 'reselect'

import root from './root'

export default {
  language: createSelector(
    root.runtime,
    runtime.language
  ),
  platform: createSelector(
    root.runtime,
    runtime.platform
  )
}

Depending on the application use case and the state structure only a specific set of selectors are needed.