1.0.3 • Published 4 years ago

react-hubx v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

react-hubx

Pubsub library to react

NPM JavaScript Style Guide

Install

npm install --save react-hubx

Usage

import React, { Component } from 'react'

import {withHubx} from 'hubx'

class App extends Component {
  
  constructor(props){
    super(props)
    
    this.onClick = this.onClick.bind(this);
    this.updateState = this.updateState.bind(this);
    this.props.attach("my-topic",this.updateState)
  }

  updateState(number){
    this.setState(s => {
      s.number = number;
      return s;
    });
  }

  onClick(){
    this.props.notify("my-topic",Math.random());
  }
  
  render () {
    return (
      <div>
        {this.state.number}
        <button>Generate</button>
      </div>
    )
  }
}


export default  withHubx(App);

License

MIT © PMoneda

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago