Options
All
  • Public
  • Public/Protected
  • All
Menu

External module @corpuscule/redux

This module provides a Redux connector for web components.

Index

Variables

Const dispatcher

dispatcher: PropertyDecorator

A default version of the @dispatcherAdvanced with the token already provided.

Const gear

gear: PropertyDecorator

A default version of the @gearAdvanced with the token already provided.

Const gearAdvanced

gearAdvanced: value

A decorator that works as a @value for the @provider.

Const isProviderAdvanced

isProviderAdvanced: isProvider

Works as a isProvider for the @provider.

Const provider

provider: ClassDecorator

A default version of the @providerAdvanced with the token already provided.

Const providerAdvanced

providerAdvanced: provider

A decorator that works as a Redux store provider. See @provider for more information.

Const redux

redux: ClassDecorator

A default version of the @reduxAdvanced with the token already provided.

Functions

createReduxToken

  • createReduxToken(): Token

dispatcherAdvanced

  • dispatcherAdvanced(token: Token): PropertyDecorator
  • A decorator that converts a class method or field (with an action creator assigned) to a redux dispatcher. Redux will dispatch everything the wrapped function returns.

    Example

    const someExternalAction = (value: string) => ({
      type: 'SOME_EXTERNAL_ACTION',
      payload: value,
    });
    
    @redux
    class ReduxExample extends HTMLElement {
      @dispatch public fieldExample = someExternalAction;
    
      private secretNumber: number = 10;
    
      @dispatch
      public methodExample(value: number) {
        return {type: 'SOME_ACTION', payload: value + this.secretNumber};
      }
    }

    Parameters

    • token: Token

      a token issued by a createReduxToken function that connects all decorators in a single working system.

    Returns PropertyDecorator

isProvider

  • isProvider(klass: unknown): boolean

reduxAdvanced

  • reduxAdvanced(token: Token): ClassDecorator
  • A decorator that makes a class declaration a Redux provider with a store as a context value. The @consumer decorator is used internally.

    note

    Do not use the @gear decorator for fields of the class declaration marked with this decorator. It will cause an error.

    Parameters

    • token: Token

      a token issued by a createReduxToken function that connects all decorators in a single working system.

    Returns ClassDecorator

unit

  • unit<S>(getter: function): PropertyDecorator
  • A default version of the @unitAdvanced with the token already provided.

    Type parameters

    • S

    Parameters

    • getter: function
        • (state: S): any
        • Parameters

          • state: S

          Returns any

    Returns PropertyDecorator

unitAdvanced

  • unitAdvanced<S>(token: Token, getter: function): PropertyDecorator
  • A decorator that makes a class property a reflection for the specific store value. Whenever the value is changed, the property receives an update as well.

    Example

    @redux
    class ReduxExample extends HTMLElement {
      @unit(store => store.foo)
      public foo!: number;
    }

    Type parameters

    • S

    Parameters

    • token: Token

      a token issued by a createReduxToken function that connects all decorators in a single working system.

    • getter: function

      a function that extracts the value to reflect from the store.

        • (state: S): any
        • Parameters

          • state: S

          Returns any

    Returns PropertyDecorator

Generated using TypeDoc