Skip to content

Commit

Permalink
docs, version and travis...
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo García Sanz committed Jul 3, 2015
1 parent ccea2cd commit 7e9faf3
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: node_js
node_js :
- "iojs"
deploy:
provider: npm
email: eduardo@comakai.com
api_key:
secure: JX1zgdfsP3rwISjl2mn6LNFOwNYcy2XIuL1mHXhAllDE5utvvaum8/zt/PWuBY7qlocGN8NZfjDsWc3PlDiezs9o0JZ0y0ipBgcPLPJJqbXc6U5EIVAUwnOMs7HorF1yz4S5T4GfBWwWfhFPr3setSHmRDTKyjmUBUqnvUj9Pq8=
on:
tags: true
repo: coma/react-socket
74 changes: 72 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,72 @@
# react-socket
A React wrapper for socket.io
react-socket
============

[![Build Status](https://travis-ci.org/coma/react-socket.png?branch=master)](https://travis-ci.org/coma/react-socket)
[![Dependency Status](https://david-dm.org/coma/react-socket.png)](http://david-dm.org/coma/react-socket)
[![NPM version](https://badge.fury.io/js/react-socket.png)](http://badge.fury.io/js/react-socket)

A React wrapper for Socket.IO

Usage
-----

Just mount a socket on one of your components:

```javascript
var React = require('react'),
Socket = require('react-socket').Socket;

module.exports = module.exports = React.createClass({
render: function () {

return (
<div>
<Socket url="your-socket-endpoint:port?"/>
</div>
);
}
});
```

and then start listening to it:

```javascript
var React = require('react'),
SocketEvent = require('react-socket').Event;

module.exports = module.exports = React.createClass({
onSocketMessage: function (message) {

...
},
render: function () {

return (
<div>
<SocketEvent name="your-socket-event" callback={ this.onSocketMessage }/>
</div>
);
}
});
```

Use the name property to mount more than one socket:

```javascript
var React = require('react'),
Socket = require('react-socket');

module.exports = module.exports = React.createClass({
render: function () {

return (
<div>
<Socket.Socket url="/a" name="a"/>
<Socket.Socket url="/b" name="b"/>
<Socket.Event socket="a" name="foo" callback={ this.onA }/>
<Socket.Event socket="b" name="foo" callback={ this.onB }/>
</div>
);
}
});
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"homepage" : "https://github.com/coma/react-socket",
"repository" : "https://github.com/coma/react-socket",
"main" : "./index.js",
"version" : "0.0.0",
"version" : "0.1.0",
"license" : "MIT",
"private" : false,
"authors" : [
Expand Down

0 comments on commit 7e9faf3

Please sign in to comment.