strudel-redux
v3.1.2
Published
Redux bindings for Strudel
Downloads
9
Readme
Strudel-redux
Package with Strudel component wrapper for combining Strudel with Redux.
Getting Started
This plugin provides simpler API for Redux with Strudel.
Installation
npm install strudel-redux --saveor
yarn add strudel-reduxExample
import { Component, Evt } from 'strudel';
import { Subscribe, AttachStore } from 'strudel-redux';
import { toggleStockStatus } from '../../actions/';
@AttachStore(store)
@Component('.example')
class Example {
init() {
store.dispatch(toggleStockStatus());
}
@Subscribe({
observed: state => ({
price: state.productDetails.price,
}),
passive: state => ({
stockStatus: state.productDetails.stockStatus,
})
})
onPriceChange({ price, stockStatus }) {
// put down your logic here
}
})API
@AttachStore(store)- required decorator to bind store to component.@Subscribe: { observed: () => {}, passive: () => {}- decorator that makes subscription to the store. Decorated method is invoked with values returned from bothobservedandpassivemethods.observedmethod that maps state to variables. Any change on one of these properties invokes decorated method.- (optional)
passivemethod that maps state to variables. Any change to one of these properties doesn't invoke decorated method.
