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.

install

npm i react-websocket-flux

Downloadsweekly downloads

8

version

0.0.1

license

none

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability