Skip to content

Commit 7e9faf3

Browse files
author
Eduardo García Sanz
committed
docs, version and travis...
1 parent ccea2cd commit 7e9faf3

File tree

3 files changed

+84
-3
lines changed

3 files changed

+84
-3
lines changed

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: node_js
2+
node_js :
3+
- "iojs"
4+
deploy:
5+
provider: npm
6+
email: eduardo@comakai.com
7+
api_key:
8+
secure: JX1zgdfsP3rwISjl2mn6LNFOwNYcy2XIuL1mHXhAllDE5utvvaum8/zt/PWuBY7qlocGN8NZfjDsWc3PlDiezs9o0JZ0y0ipBgcPLPJJqbXc6U5EIVAUwnOMs7HorF1yz4S5T4GfBWwWfhFPr3setSHmRDTKyjmUBUqnvUj9Pq8=
9+
on:
10+
tags: true
11+
repo: coma/react-socket

README.md

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,72 @@
1-
# react-socket
2-
A React wrapper for socket.io
1+
react-socket
2+
============
3+
4+
[![Build Status](https://travis-ci.org/coma/react-socket.png?branch=master)](https://travis-ci.org/coma/react-socket)
5+
[![Dependency Status](https://david-dm.org/coma/react-socket.png)](http://david-dm.org/coma/react-socket)
6+
[![NPM version](https://badge.fury.io/js/react-socket.png)](http://badge.fury.io/js/react-socket)
7+
8+
A React wrapper for Socket.IO
9+
10+
Usage
11+
-----
12+
13+
Just mount a socket on one of your components:
14+
15+
```javascript
16+
var React = require('react'),
17+
Socket = require('react-socket').Socket;
18+
19+
module.exports = module.exports = React.createClass({
20+
render: function () {
21+
22+
return (
23+
<div>
24+
<Socket url="your-socket-endpoint:port?"/>
25+
</div>
26+
);
27+
}
28+
});
29+
```
30+
31+
and then start listening to it:
32+
33+
```javascript
34+
var React = require('react'),
35+
SocketEvent = require('react-socket').Event;
36+
37+
module.exports = module.exports = React.createClass({
38+
onSocketMessage: function (message) {
39+
40+
...
41+
},
42+
render: function () {
43+
44+
return (
45+
<div>
46+
<SocketEvent name="your-socket-event" callback={ this.onSocketMessage }/>
47+
</div>
48+
);
49+
}
50+
});
51+
```
52+
53+
Use the name property to mount more than one socket:
54+
55+
```javascript
56+
var React = require('react'),
57+
Socket = require('react-socket');
58+
59+
module.exports = module.exports = React.createClass({
60+
render: function () {
61+
62+
return (
63+
<div>
64+
<Socket.Socket url="/a" name="a"/>
65+
<Socket.Socket url="/b" name="b"/>
66+
<Socket.Event socket="a" name="foo" callback={ this.onA }/>
67+
<Socket.Event socket="b" name="foo" callback={ this.onB }/>
68+
</div>
69+
);
70+
}
71+
});
72+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"homepage" : "https://github.com/coma/react-socket",
55
"repository" : "https://github.com/coma/react-socket",
66
"main" : "./index.js",
7-
"version" : "0.0.0",
7+
"version" : "0.1.0",
88
"license" : "MIT",
99
"private" : false,
1010
"authors" : [

0 commit comments

Comments
 (0)