https://github.com/co2-git/trunks
Minimalistic Flux stores for React
https://github.com/co2-git/trunks
Last synced: about 1 year ago
JSON representation
Minimalistic Flux stores for React
- Host: GitHub
- URL: https://github.com/co2-git/trunks
- Owner: co2-git
- Created: 2016-07-06T00:12:45.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-27T19:15:31.000Z (over 9 years ago)
- Last Synced: 2025-03-19T08:48:42.346Z (over 1 year ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
trunks
===
Minimalistic stores for React.
# Usage
Create a store:
```javascript
// 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:
```javascript
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 (
CounterActions.click()}>
This button has been clicked {CounterStore.clicked} times
);
}
}
// Don't forget to connect your component!
// You can listen to more than one store
export default connect(ClickCounter, {Counter});
```