0.0.10 • Published 10 years ago

trunks v0.0.10

Weekly downloads
3
License
ISC
Repository
github
Last release
10 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

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago