0.0.10 • Published 8 years ago

trunks v0.0.10

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

trunks

Minimalistic stores for React.

Usage

Create a store:

// counter.js
import Trunk from 'trunks';

export default class MyTrunk extends Trunk {
  // declare your store here
  static store = Trunk.map({
    clicked: 0,
  });

  click() {
    this.set({clicked: this.get('store') + 1});
  }
}

In your view:

import React, {Component} from 'react';
import {connect} from 'trunks';
import Counter from './Counter';

class ClickCounter extends Component {
  render() {
    const {Counter: CounterStore} = this.props.trunks.stores;
    const {Counter: CounterActions} = this.props.trunks.actions;
    return (
      <button onClick={() => CounterActions.click()}>
        This button has been clicked {CounterStore.clicked} times
      </button>
    );
  }
}

// Don't forget to connect your component!
// You can listen to more than one store
export default connect(ClickCounter, {Counter});
0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago