Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Reducers

Module for defining Redux reducers.

Actions describe the fact that something happened, but don't specify how the application's state changes in response. This is the job of a reducer.

Following module contains the reducers of sn-redux, some 'reducer groups' and the root reducer which could be passed to the store creator function. Using a root reduces means that you define which combination of reducers will be used and eventually defines which type of actions can be called on the store.

Index

Variables

collection

collection: function = combineReducers({byId,ids,isFetching,errorMessage,user})

Reducer combining byId object, ids array, isFetching and errorMessage into a single object which means collection will be a top object in the state.

Type declaration

    • <A>(state: S, action: A): S
    • Type parameters

      • A: Action

      Parameters

      • state: S
      • action: A

      Returns S

snApp

snApp: function = combineReducers({collection})

Reducer to hold the collection object and represent a root reducer of a SenseNet Redux application store. If you want to add your custom Reducers to the store, create your own root Reducer combining collection and your top Reducer.

Type declaration

    • <A>(state: S, action: A): S
    • Type parameters

      • A: Action

      Parameters

      • state: S
      • action: A

      Returns S

Functions

byId

  • byId(state?: object, action: any): any
  • Reducer to handle Actions on the byId Object in the state, which is a dictionary with normalized nested JSON response. It becomes the current state and an action as arguments, creates a new state based on the previous state and the action and returns it as the next state. If the Action doesn't affect the state the returned state will be the current state itself.

    Parameters

    • Default value state: object = {}
    • action: any

      Represents an action that is called.

    Returns any

    state. Returns the next state based on the action.

errorMessage

  • errorMessage(state?: any, action: any): any
  • Reducers to set the errormessage in the state if a process is failed. If the Action doesn't affect the state the returned state will be the current state itself.

    Parameters

    • Default value state: any = null
    • action: any

      Represents the action that is called.

    Returns any

    state. Returns the next state based on the action.

getAuthenticationError

  • getAuthenticationError(state: any): any
  • Parameters

    • state: any

    Returns any

getAuthenticationStatus

  • getAuthenticationStatus(state: any): any
  • Parameters

    • state: any

    Returns any

getContent

  • getContent(state: Object, Id: number): any
  • Method to get a Content item from a state object by its Id.

    Parameters

    • state: Object

      Current state object.

    • Id: number

      Id of the Content.

    Returns any

    content. Returns the Content from a state object with the given Id.

getError

  • getError(state: any): any
  • Method to get the error message.

    Parameters

    • state: any

      Current state object.

    Returns any

    Returns the error message.

getFetching

  • getFetching(state: any): any
  • Method to get if the fetching of data is in progress.

    Parameters

    • state: any

      Current state object.

    Returns any

    Returns true or false whether data fetching is in progress or not.

getIds

  • getIds(state: any): any
  • Method to get the ids array from a state object.

    Parameters

    • state: any

      Current state object.

    Returns any

    content. Returns the ids array from the given state.

ids

  • ids(state?: Array<any>, action: any): any
  • Reducers to handle Actions on the ids Array in the state, which is the list Ids of the Content in the byId Object. It becomes the current state of the ids array and an action creates a new array based on the current one and the action and returns it as the next state of the ids array. If the Action doesn't affect the state the returned state will be the current state itself.

    Parameters

    • Default value state: Array<any> = []

      Represents the current state.

    • action: any

      Represents the action that is called.

    Returns any

    state. Returns the next state based on the action.

isFetching

  • isFetching(state?: boolean, action: any): boolean
  • Reducers to set in the state if the data is fetching or not. If the Action doesn't affect the state the returned state will be the current state itself.

    Parameters

    • Default value state: boolean = false
    • action: any

      Represents the action that is called.

    Returns boolean

    state. Returns the next state based on the action.

user

  • user(state?: object, action: any): object | object
  • Reducer to handle Actions on the user Object in the state. It becomes the current state and an action as arguments, creates a new state based on the previous state and the action and returns it as the next state. If the Action doesn't affect the state the returned state will be the current state itself.

    Parameters

    • Default value state: object = userInitialState
      • data: null
      • errorMessage: string
      • isAuthenticated: boolean
      • isLoading: boolean
    • action: any

      Represents an action that is called.

    Returns object | object

    state. Returns the next state based on the action.

Object literals

userInitialState

userInitialState: object

data

data: null = null

errorMessage

errorMessage: string = ""

isAuthenticated

isAuthenticated: boolean = false

isLoading

isLoading: boolean = false

Generated using TypeDoc