Class: Store

store.Store(reducer, initialState)

A simple store compatible with Redux.

Constructor

new Store(reducer, initialState)

Creates a new store with the given reducer and initial state.

Parameters:
Name Type Description
reducer ReducerType
initialState StateType

Methods

dispatch(action)

Updates the state of the store by dispatching an action to the reducer.

Parameters:
Name Type Description
action ActionType

The action to dispatch.

getState() → {StateType}

Returns the current state of the store.

Returns:

The current state of the store.

Type
StateType

subscribe(listener) → {UnsubscriberType}

Subscribes a listener to store changes.

Parameters:
Name Type Description
listener ListenerType

The listener to subscribe.

Returns:

A function that unsubscribes the listener.

Type
UnsubscriberType