0.0.1 • Published 8 years ago

react-websocket-flux v0.0.1

Weekly downloads
9
License
-
Repository
github
Last release
8 years ago

react-websocket-flux: React application over Websocket based on Flux

Install

To setup the package.

npm install react-websocket-flux --save

Quickstart

import { WebsocketStore, WebsocketActions } from 'react-websocket-view';

export class MyApp extends Component {
    constructor(props, context) {
        super(props, context);

        this.onMessage = this.onMessage.bind(this);
        WebsocketActions.connect(this.props.server);
    }

    componentDidMount() {
        WebsocketStore.addMessageListener(this.onMessage);
    }

    componentWillUnmount() {
        WebsocketStore.removeMessageListener(this.onMessage);      
    }

    onMessage(data) {
        this.setState(data)
    }

    render() {
        return (    
            <div>
            </div>
        );
    }
}

License

The MIT License (MIT). See LICENSE.md.