Options
All
  • Public
  • Public/Protected
  • All
Menu

Class StoreService

Hierarchy

  • StoreService

Index

Constructors

constructor

Properties

_factory

_httpService

_httpService: HTTPService

_moduleNames

_moduleNames: string[]

_store

_store: Store<any>

Accessors

responseMiddleware

  • The store service response middleware checks if any of the known modulenames is in the data of the response When there is a modulename in the response it dispatches an action to that module to set the response data in the store

    Returns ResponseMiddleware

storeSeperator

  • get storeSeperator(): string

Methods

checkIfRequestedModuleExists

  • checkIfRequestedModuleExists(moduleName: string): void
  • Checks if requested module exists in the store If not, throws a StoreModuleNotFoundError

    throws

    {StoreModuleNotFoundError}

    Parameters

    • moduleName: string

    Returns void

create

  • create(moduleName: string, item: Item): Promise<any>
  • dispatch an action to the store, which creates an item on the server

    Parameters

    • moduleName: string

      the store module for which an item must be created

    • item: Item

      the item to be created

    Returns Promise<any>

createExtraGetAction

  • createExtraGetAction(endpoint: string, options?: AxiosRequestConfig): {}
  • create a new action to add to the store which sends a get request

    Parameters

    • endpoint: string

      api endpoint

    • Optional options: AxiosRequestConfig

    Returns {}

    • [x: string]: (_: any, payload: any) => Promise<AxiosResponse<any>>
        • (_: any, payload: any): Promise<AxiosResponse<any>>
        • Parameters

          • _: any
          • payload: any

          Returns Promise<AxiosResponse<any>>

createExtraPostAction

  • createExtraPostAction(endpoint: string, actionName: string): {}
  • create a new action to add to the store which sends a post request

    Parameters

    • endpoint: string

      api endpoint

    • actionName: string

      the last part of the url

    Returns {}

    • [x: string]: (_: any, payload: any) => Promise<AxiosResponse<any>>
        • (_: any, payload: any): Promise<AxiosResponse<any>>
        • Parameters

          • _: any
          • payload: any

          Returns Promise<AxiosResponse<any>>

destroy

  • destroy(moduleName: string, id: string): Promise<any>
  • dispatch an action to the store, which deletes an item on the server

    Parameters

    • moduleName: string

      the store module for which an item must be deleted

    • id: string

      the id of the item to be deleted

    Returns Promise<any>

dispatch

  • dispatch(moduleName: string, action: string, payload: any): Promise<any>
  • dispatch an action to the store

    Parameters

    • moduleName: string

      the name of the module to dispatch the action to

    • action: string

      the name of the action

    • payload: any

      the payload to sent to the action

    Returns Promise<any>

generateAndSetDefaultStoreModule

  • generateAndSetDefaultStoreModule(moduleName: string, endpoint?: string, extraFunctionality?: Module<string, any>): void
  • generate and set the default store module in the store

    Parameters

    • moduleName: string

      the name of the module

    • Optional endpoint: string
    • Optional extraFunctionality: Module<string, any>

    Returns void

get

  • get(moduleName: string, getter: string): any
  • get something from the store

    Parameters

    • moduleName: string

      the name of the module to get something from

    • getter: string

      the name of the getter

    Returns any

getAllFromStore

  • getAllFromStore(moduleName: string): Item[]
  • Get all from data from the given store module

    Parameters

    • moduleName: string

      the module from which to get all

    Returns Item[]

getAllItemsStateName

  • getAllItemsStateName(seperator?: boolean): string
  • get the all data in store state name with or without seperator

    Parameters

    • Optional seperator: boolean

    Returns string

getByIdFromStore

  • getByIdFromStore(moduleName: string, id: string): Item
  • Get all data from the given store module by id

    Parameters

    • moduleName: string

      the module from which to get all

    • id: string

      the id of the data object to get

    Returns Item

getCreateAction

  • getCreateAction(seperator?: boolean): string
  • get the update store action with or without seperator

    Parameters

    • Optional seperator: boolean

    Returns string

getDeleteAction

  • getDeleteAction(seperator?: boolean): string
  • get the delete store action with or without seperator

    Parameters

    • Optional seperator: boolean

    Returns string

getDeleteMutation

  • getDeleteMutation(seperator?: boolean): string
  • get the delete mutation name with or without seperator

    Parameters

    • Optional seperator: boolean

    Returns string

getReadAction

  • getReadAction(seperator?: boolean): string
  • get the read store action with or without seperator

    Parameters

    • Optional seperator: boolean

    Returns string

getReadAllGetter

  • getReadAllGetter(seperator?: boolean): string
  • get the read all from store getter with or without seperator

    Parameters

    • Optional seperator: boolean

    Returns string

getReadByIdGetter

  • getReadByIdGetter(seperator?: boolean): string
  • get the read by id from store getter with or without seperator

    Parameters

    • Optional seperator: boolean

    Returns string

getSetAllInStoreAction

  • getSetAllInStoreAction(seperator?: boolean): string
  • get the set all in store action with or without seperator

    Parameters

    • Optional seperator: boolean

    Returns string

getSetAllMutation

  • getSetAllMutation(seperator?: boolean): string
  • get the set all mutation name with or without seperator

    Parameters

    • Optional seperator: boolean

    Returns string

getUpdateAction

  • getUpdateAction(seperator?: boolean): string
  • get the update store action with or without seperator

    Parameters

    • Optional seperator: boolean

    Returns string

read

  • read(moduleName: string): Promise<any>
  • dispatch an action to the store, which reads all items on the server

    Parameters

    • moduleName: string

      the store module for which all items must be read

    Returns Promise<any>

registerModule

  • registerModule(moduleName: string, storeModule: Module<string, any>): void
  • set the store module in the store

    Parameters

    • moduleName: string

      the name of the module

    • storeModule: Module<string, any>

      the module to add to the store

    Returns void

setAllInStore

  • setAllInStore(moduleName: string, data: Item | Item[]): Promise<any>
  • Set all the data in the store module

    Parameters

    • moduleName: string

      the module to fill the data with

    • data: Item | Item[]

      data to fill the store with

    Returns Promise<any>

setFactorySettings

  • setFactorySettings(): void

show

  • show(moduleName: string, id: number): Promise<any>
  • dispatch an action to the store, which reads an item on the server

    Parameters

    • moduleName: string

      the store module for which the item must be read

    • id: number

      the id to be read

    Returns Promise<any>

update

  • update(moduleName: string, item: Item): Promise<any>
  • dispatch an action to the store, which updates an item on the server

    Parameters

    • moduleName: string

      the store module for which an item must be updated

    • item: Item

      the item to be updated

    Returns Promise<any>

Generated using TypeDoc