1.2.1 • Published 4 years ago

redux-simple-event v1.2.1

Weekly downloads
42
License
ISC
Repository
github
Last release
4 years ago

redux-simple-event

  • npm i redux-simple-event
// store.js
const { ReduxSimpleEvent } = require('redux-simple-event');

class Store extends ReduxSimpleEvent {
  // methods
}

module.exports = new Store()

Usage

Example:

// Setting a value on state
store.setState('member.name', 'John');

// Getting a state value
store.getState();

// General listener
store.addListener('change', func);

// Or specific listener
store.addListener('change-member-name', func);

Server side:

module.exports = new ReduxSimpleEvent({ foo: 'bar' }, { browser: false });

Marko Usage

You can use <provider /> component to encapsulate store.

// my-store-instance.js

module.exports = new ReduxSimpleEvent({ foo: 'bar' });
// index.marko

$ const myStoreInstance = require('../my-store-instance');

provider store=myStoreInstance
  @content|{ store }|
    inner-component ...store
// inner-component/index.marko

div -- ${ input.store.getState().foo}
// or
div -- ${ input.foo }
1.2.0

4 years ago

1.2.1

4 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago