npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@acoustic-content-sdk/redux-store

v9.0.10076

Published

Implementation of a Redux store with support for adding feature modules, dynamically.

Downloads

102

Readme

npm

Implementation of a Redux store with support for adding feature modules, dynamically.

Providing a feature module

Create and export an instance of ReduxFeatureModule for your module.

Example

import {
  ReduxFeatureModule,
  createReduxFeatureModule
} from '@acoustic-content-sdk/redux-store';

import { sampleEpic } from './feature.epics';
import { sampleReducer } from './feature.reducer';
import { SampleFeatureState } from './feature.state';

export const sampleFeature = createReduxFeatureModule(
  'SAMPLE_FEATURE',
  sampleReducer,
  sampleEpic
);

In some cases a feature module depends on the existence on other feature modules, e.g. because an epic might require it. In this case list the modules the feature modules depends on in the dependencies parameter:

import {
  ReduxFeatureModule,
  createReduxFeatureModule
} from '@acoustic-content-sdk/redux-store';

import { sampleEpic } from './feature.epics';
import { sampleReducer } from './feature.reducer';
import { SampleFeatureState } from './feature.state';

export const sampleFeature = createReduxFeatureModule(
  'SAMPLE_FEATURE',
  sampleReducer,
  sampleEpic,
  [depModule1, depModule2, depModule3]
);

Registering a feature module

Register the feature module with the root store using the addFeatureModule method. This will also register all dependent modules in topology order.

import {
  ReduxRootStore
} from '@acoustic-content-sdk/redux-store';

const store: ReduxRootStore = ...;

store.addFeatureModule(sampleFeature);

Consuming a feature module

Use the selectFeature method to create a selector for the desired feature.

Example

import { selectFeature } from '@acoustic-content-sdk/redux-store';

const selectSample = selectFeature(sampleFeature);

Side effects in Feature Modules

Feature modules may provide side effects (Epics) for asynchronous processing. Sometimes such epics require an initialization event to execute bootstrapping logic. The store sends an initialization event for this purpose, after a feature module has been initialized. Use the ofInitFeature method to subscribe to this event.

Example

import { ofInitFeature } from '@acoustic-content-sdk/redux-store';

const initEpic: Epic = (actions$) =>
  actions$.pipe(ofInitFeature(sampleFeature), map(...));

API Documentation

API Documentation

Home > @acoustic-content-sdk/redux-store

redux-store package

Implementation of a Redux store with support for adding feature modules, dynamically.

Functions

| Function | Description | | --- | --- | | createIdentifier(idOrModuleId, aValue) | Scopes the given ID with a feature prefix to make it unique | | createReduxFeatureModule(idOrModuleId, reducer, epic, dependencies) | Convenience method to create a feature module | | createReduxMetaModule(dependencies) | Convenience method to create a meta module, i.e. a module that bundles other modules | | createReduxRootStore(aDependencies, aPreLoadedState) | Constructs a new store that can handle feature modules. | | featureModuleId(id) | Constructs a feature module ID that carries type information | | ofInitFeature(idOrModuleId) | Returns an operator function that filters the initialization actions for a particular feature. This is typically used in feature epics. Since we know that an initialization can occur at most once, the operator also terminates automatically after the first emission. | | rxSelectFeature(idOrModuleId) | Returns a selector that selects the given feature from the store and returns an observable to that feature state. | | rxStore(aStore) | Exposes the store as an Observable. |

Interfaces

| Interface | Description | | --- | --- | | PayloadAction | Base class for actions that carry a payload. Use the selectPayload method to extract the payload. | | ReduxFeatureModule | Defines the feature module. The ID identifies the section in the state and is also used to globally discriminate features.After instantiating a feature store the store will fire an initialization action for that feature. Use ofInitFeature() to register for these initialization actions. | | ReduxFeatureModuleId | Feature module identifier. This wrapper around an ID is useful, because it carries type information. | | ReduxRootStore | Implementation of a store that manages sub-state as features. Features are added to the store automatically, when required by the select method. | | ReduxRootStoreDependencies | Dependencies object available for epics |

Variables

| Variable | Description | | --- | --- | | rxDispatch | Binds the dispatch method | | rxSelect | Exposes a memoized selector function | | selectFeature | Returns a selector that selects the given feature | | selectPayload | Selects the payload from a PayloadAction instance | | STORE_ID | Exposes the namespace of this store. This constant can e.g. be used to prefix actions. | | VERSION | Version and build number of the package |

Type Aliases

| Type Alias | Description | | --- | --- | | ReduxRootState | Root state for the reducer, this is a mapping from feature ID to feature. |

Home > @acoustic-content-sdk/redux-store > createIdentifier

createIdentifier() function

Scopes the given ID with a feature prefix to make it unique

Signature:

export declare function createIdentifier(idOrModuleId: string | ReduxFeatureModuleId<any, any>, aValue?: string): string;

Parameters

| Parameter | Type | Description | | --- | --- | --- | | idOrModuleId | string | ReduxFeatureModuleId<any, any> | the module | | aValue | string | optionally a identifier, will create a random identifier otherwise |

Returns:

string

the new identifier

Home > @acoustic-content-sdk/redux-store > createReduxFeatureModule

createReduxFeatureModule() function

Convenience method to create a feature module

Signature:

export declare function createReduxFeatureModule<S, FS = any, Input extends Action = AnyAction, Output extends Input = Input, Dependencies = any>(idOrModuleId?: string | ReduxFeatureModuleId<S, FS>, reducer?: Reducer<S>, epic?: Epic<Input, Output, ReduxRootState, Dependencies>, dependencies?: ArrayLike<ReduxFeatureModule<any>>): ReduxFeatureModule<S, FS>;

Parameters

| Parameter | Type | Description | | --- | --- | --- | | idOrModuleId | string | ReduxFeatureModuleId<S, FS> | ID of the store, if not set, generate a random identifier | | reducer | Reducer<S> | optionally the reducer | | epic | Epic<Input, Output, ReduxRootState, Dependencies> | optionally the epic | | dependencies | ArrayLike<ReduxFeatureModule<any>> | optionally the dependencies on other modules |

Returns:

ReduxFeatureModule<S, FS>

a ReduxFeatureModule instance

Home > @acoustic-content-sdk/redux-store > createReduxMetaModule

createReduxMetaModule() function

Convenience method to create a meta module, i.e. a module that bundles other modules

Signature:

export declare function createReduxMetaModule<FS = any>(dependencies: ArrayLike<ReduxFeatureModule<any>>): ReduxFeatureModule<any, FS>;

Parameters

| Parameter | Type | Description | | --- | --- | --- | | dependencies | ArrayLike<ReduxFeatureModule<any>> | dependencies on other modules |

Returns:

ReduxFeatureModule<any, FS>

a ReduxFeatureModule instance

Home > @acoustic-content-sdk/redux-store > createReduxRootStore

createReduxRootStore() function

Constructs a new store that can handle feature modules.

Signature:

export declare function createReduxRootStore(aDependencies: any, aPreLoadedState?: ReduxRootState): ReduxRootStore;

Parameters

| Parameter | Type | Description | | --- | --- | --- | | aDependencies | any | the dependencies that will be injected into the epics | | aPreLoadedState | ReduxRootState | optionally an initial state object |

Returns:

ReduxRootStore

the store. Use the ReduxRootStore.addFeatureModule() method to register a feature module.

Home > @acoustic-content-sdk/redux-store > featureModuleId

featureModuleId() function

Constructs a feature module ID that carries type information

Signature:

export declare function featureModuleId<S, FS = any>(id?: string): ReduxFeatureModuleId<S, FS>;

Parameters

| Parameter | Type | Description | | --- | --- | --- | | id | string | the module identifier or empty to create a random identifier |

Returns:

ReduxFeatureModuleId<S, FS>

the ID

Home > @acoustic-content-sdk/redux-store > ofInitFeature

ofInitFeature() function

Returns an operator function that filters the initialization actions for a particular feature. This is typically used in feature epics. Since we know that an initialization can occur at most once, the operator also terminates automatically after the first emission.

Signature:

export declare function ofInitFeature<A = AnyAction>(idOrModuleId: string | ReduxFeatureModuleId<any, any>): OperatorFunction<A, string>;

Parameters

| Parameter | Type | Description | | --- | --- | --- | | idOrModuleId | string | ReduxFeatureModuleId<any, any> | the feature ID to filter for |

Returns:

OperatorFunction<A, string>

the operator function that filters for the initialization action and resolves to the ID of the feature

Home > @acoustic-content-sdk/redux-store > rxSelectFeature

rxSelectFeature() function

Returns a selector that selects the given feature from the store and returns an observable to that feature state.

Signature:

export declare function rxSelectFeature<S, FS = any>(idOrModuleId: string | ReduxFeatureModuleId<S, FS>): UnaryFunction<ReduxRootStore, Observable<S>>;

Parameters

| Parameter | Type | Description | | --- | --- | --- | | idOrModuleId | string | ReduxFeatureModuleId<S, FS> | ID of the module |

Returns:

UnaryFunction<ReduxRootStore, Observable<S>>

an observable with the feature selected

Home > @acoustic-content-sdk/redux-store > rxStore

rxStore() function

Exposes the store as an Observable.

Signature:

export declare function rxStore<S>(aStore: Store<S>): Observable<S>;

Parameters

| Parameter | Type | Description | | --- | --- | --- | | aStore | Store<S> | the store |

Returns:

Observable<S>

the store as an Observable

Home > @acoustic-content-sdk/redux-store > PayloadAction

PayloadAction interface

Base class for actions that carry a payload. Use the selectPayload method to extract the payload.

Signature:

export interface PayloadAction<T> extends Action 

Properties

| Property | Type | Description | | --- | --- | --- | | payload | T | |

Home > @acoustic-content-sdk/redux-store > selectPayload

selectPayload variable

Selects the payload from a PayloadAction instance

Signature:

selectPayload: <T>(aAction: PayloadAction<T>) => T

Home > @acoustic-content-sdk/redux-store > ReduxFeatureModule

ReduxFeatureModule interface

Defines the feature module. The ID identifies the section in the state and is also used to globally discriminate features.

After instantiating a feature store the store will fire an initialization action for that feature. Use ofInitFeature() to register for these initialization actions.

Signature:

export interface ReduxFeatureModule<S, FS = any, Input extends Action = AnyAction, Output extends Input = Input, Dependencies = any> extends ReduxFeatureModuleId<S, FS> 

Properties

| Property | Type | Description | | --- | --- | --- | | dependencies | ArrayLike<ReduxFeatureModule<any>> | Dependencies on other modules | | epic | Epic<Input, Output, ReduxRootState, Dependencies> | The epic for side effects | | id | string | ID of the feature module, will also be used as the key to the state | | reducer | Reducer<S> | The reducer for the module. |

Home > @acoustic-content-sdk/redux-store > ReduxFeatureModuleId

ReduxFeatureModuleId interface

Feature module identifier. This wrapper around an ID is useful, because it carries type information.

Signature:

export interface ReduxFeatureModuleId<S, FS = any> 

Properties

| Property | Type | Description | | --- | --- | --- | | id | string | ID of the feature module, will also be used as the key to the state |

Home > @acoustic-content-sdk/redux-store > ReduxRootStore

ReduxRootStore interface

Implementation of a store that manages sub-state as features. Features are added to the store automatically, when required by the select method.

Signature:

export interface ReduxRootStore<S = ReduxRootState, A extends Action = AnyAction> extends Store<S, A> 

Methods

| Method | Description | | --- | --- | | addFeatureModule(aFeature) | Registers a feature module with the root store |

Home > @acoustic-content-sdk/redux-store > ReduxRootStoreDependencies

ReduxRootStoreDependencies interface

Dependencies object available for epics

Signature:

export interface ReduxRootStoreDependencies 

Properties

| Property | Type | Description | | --- | --- | --- | | logSvc | LoggerService | Service that allows to create logger instances | | rootStore | ReduxRootStore | The root store dependencies |

Home > @acoustic-content-sdk/redux-store > rxDispatch

rxDispatch variable

Binds the dispatch method

Signature:

rxDispatch: <S>(aStore: Store<S>) => Consumer<AnyAction>

Home > @acoustic-content-sdk/redux-store > rxSelect

rxSelect variable

Exposes a memoized selector function

Signature:

rxSelect: <T, R>(aSelector: UnaryFunction<T, R>, aCmp?: EqualsPredicate<R>) => OperatorFunction<T, R>

Home > @acoustic-content-sdk/redux-store > selectFeature

selectFeature variable

Returns a selector that selects the given feature

Signature:

selectFeature: <S, FS = any>(idOrModuleId: string | ReduxFeatureModuleId<S, FS>, aDefaultState?: S) => UnaryFunction<ReduxRootState, S>

Home > @acoustic-content-sdk/redux-store > STORE_ID

STORE_ID variable

Exposes the namespace of this store. This constant can e.g. be used to prefix actions.

Signature:

STORE_ID = "@acoustic-content-sdk/redux-store"

Home > @acoustic-content-sdk/redux-store > VERSION

VERSION variable

Version and build number of the package

Signature:

VERSION: {
    version: {
        major: string;
        minor: string;
        patch: string;
        branch: string;
    };
    build: Date;
}

Home > @acoustic-content-sdk/redux-store > ReduxRootState

ReduxRootState type

Root state for the reducer, this is a mapping from feature ID to feature.

Signature:

export declare type ReduxRootState = Record<string, any>;

Home > @acoustic-content-sdk/redux-store > ReduxRootStore > addFeatureModule

ReduxRootStore.addFeatureModule() method

Registers a feature module with the root store

Signature:

addFeatureModule<RFS = any, FS = any>(aFeature: ReduxFeatureModule<RFS, FS>): ReduxRootStore<FS, A>;

Parameters

| Parameter | Type | Description | | --- | --- | --- | | aFeature | ReduxFeatureModule<RFS, FS> | the feature model |

Returns:

ReduxRootStore<FS, A>

Home > @acoustic-content-sdk/redux-store > PayloadAction > payload

PayloadAction.payload property

Signature:

[ACTION_PAYLOAD]: T;

Home > @acoustic-content-sdk/redux-store > ReduxFeatureModuleId > id

ReduxFeatureModuleId.id property

ID of the feature module, will also be used as the key to the state

Signature:

id: string;

Home > @acoustic-content-sdk/redux-store > ReduxFeatureModule > dependencies

ReduxFeatureModule.dependencies property

Dependencies on other modules

Signature:

dependencies?: ArrayLike<ReduxFeatureModule<any>>;

Home > @acoustic-content-sdk/redux-store > ReduxFeatureModule > epic

ReduxFeatureModule.epic property

The epic for side effects

Signature:

epic?: Epic<Input, Output, ReduxRootState, Dependencies>;

Home > @acoustic-content-sdk/redux-store > ReduxFeatureModule > id

ReduxFeatureModule.id property

ID of the feature module, will also be used as the key to the state

Signature:

id: string;

Home > @acoustic-content-sdk/redux-store > ReduxFeatureModule > reducer

ReduxFeatureModule.reducer property

The reducer for the module.

Signature:

reducer?: Reducer<S>;

Home > @acoustic-content-sdk/redux-store > ReduxRootStoreDependencies > logSvc

ReduxRootStoreDependencies.logSvc property

Service that allows to create logger instances

Signature:

logSvc: LoggerService;

Home > @acoustic-content-sdk/redux-store > ReduxRootStoreDependencies > rootStore

ReduxRootStoreDependencies.rootStore property

The root store dependencies

Signature:

rootStore: ReduxRootStore;