react-websocket-flux

0.0.1 • Public • Published

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.

Dependents (1)

Package Sidebar

Install

npm i react-websocket-flux

Weekly Downloads

5

Version

0.0.1

License

none

Last publish

Collaborators

  • jollen