refractEnhancer (Redux)

Used to enhance a Redux store, adding observable functionality which can be used inside Refract.

Packages

refractEnhancer is provided by our Redux packages - refract-redux-callbag, refract-redux-most, refract-redux-rxjs, and refract-redux-xstream.

Signature

refractEnhancer = (options?) => {
    return StoreCreator
}

Arguments

  1. options (object): an object which configures the Refract store enhancer.

    Two options are currently available for the refractEnhancer:

    • eventsPrefix (string): defines an actionType prefix which marks actions which are not intended to be forwarded to your reducers. Refract will intercept these, preventing them from touching your state (or any downstream store enhancers), but will forward them on to any watching apertures. (default: @@event/)

    • methodName (string): customises the name used for the store.observe method. (default: observe)

      Note that customising the methodName option with TypeScript will break the Redux Store interface, which is extended when you import the Refract enhancer. To use this option with TypeScript, you will need to extend the interface - for example:

      import { StoreObserveFunction } from 'refract-redux-rxjs'
      
      declare module 'redux' {
          interface Store {
              observeWithRxjs: StoreObserveFunction
          }
      }

Returns

StoreCreator (Redux store creator): a function which creates a redux store. Note that you should not be calling this function directly, and instead should be passing it into Redux createStore.

Example

import { createStore } from 'redux'
import { refractEnhancer } from 'refract-redux-rxjs'
import rootReducer from './reducers'

export default function configureStore() {
    const store = createStore(rootReducer, null, refractEnhancer())

    return store
}

Read more about configuring your Redux store here!

Last updated