Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dist: trusty
sudo: false
language: node_js
node_js:
- 'stable'
cache:
directories:
- node_modules
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
oo7-react
=========

A small library to provide integration between React and `Bond`s.
A small library to provide integration between React and [`Bond`s](https://github.com/ethcore/oo7#oo7).

Provides two React components: `ReactiveComponent` and `Reactive`. The first
provides an alternative to `React.Component` for classes whose state shall
Expand All @@ -18,47 +18,47 @@ The element will stay updated to the latest value of each expression.
## Installation

```sh
npm install oo7-react --save
npm install oo7-react --save
```

## Usage

```javascript
// Assume React is already required.
var oo7react = require('oo7-react'),
setupBonds = oo7parity.setupBonds,
formatBlockNumber = oo7parity.formatBlockNumber;
// Assume React is already required.
var oo7react = require('oo7-react'),
setupBonds = oo7parity.setupBonds,
formatBlockNumber = oo7parity.formatBlockNumber;

class DateFormatter extends ReactiveComponent {
constructor() {
// Tell the object to look out for 'date' prop and keep the 'date'
// state up to date.
super(['date']);
}
render() {
return this.state.date === null ?
<div>Date unknown</div> :
<div>The date is {this.state.date}</div>;
}
}
class DateFormatter extends ReactiveComponent {
constructor() {
// Tell the object to look out for 'date' prop and keep the 'date'
// state up to date.
super(['date']);
}
render() {
return this.state.date === null ?
<div>Date unknown</div> :
<div>The date is {this.state.date}</div>;
}
}

class App extends React.Component {
render() {
// Evaluates to a pretty datetime.
let b = (new TimeBond).map(t => new Date(t) + '');
// Prints two clocks. They both print the time and stay up to date.
return (<div>
<DateFormatter date={b} />
<div>The date is: <Reactive value={b} /></div>
</div>)
}
}
class App extends React.Component {
render() {
// Evaluates to a pretty datetime.
let b = (new TimeBond).map(t => new Date(t) + '');
// Prints two clocks. They both print the time and stay up to date.
return (<div>
<DateFormatter date={b} />
<div>The date is: <Reactive value={b} /></div>
</div>)
}
}
```

## Tests

```sh
npm test
npm test
```

## Contributing
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
"version": "0.1.2",
"description": "The Reactive Bond API",
"main": "lib/index.js",
"jsnext:main": "src/index.jsx",
"files": [
"lib/*"
"lib/*",
"src/*"
],
"scripts": {
"test": "npm run compile && mocha --compilers js:babel-core/register --reporter spec",
"test": "npm run compile && mocha --compilers js:babel-core/register --reporter spec",
"compile": "babel --presets es2015,react -d lib/ src/",
"prepublish": "npm run compile"
},
Expand All @@ -31,7 +33,8 @@
"dependencies": {
"material-ui": "^0.16.7",
"oo7": "^0.1.2",
"react": "^15.4.2"
"react": "^15.4.2",
"react-dom": "^15.4.2"
},
"devDependencies": {
"babel-cli": "^6.22.2",
Expand Down