@pupper/pupper-react
PHP + React
Last updated 2 years ago by bouiboui .
Unlicense · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @pupper/pupper-react 
SYNC missed versions from official npm registry.

d005d89e-ff25-4450-9119-aa56ff0d8949

Software License

Pupper stands for "PHP Plus React" (PPR > Pupper). The goal is to make a Framework that takes the best of both technologies and makes them communicate bi-directionnaly.

See pupper on Github for more information

API

SocketProvider

SocketProvider takes a WebSocket as a prop and hydrates it to its child components.

It can automatically bind them by using the bindTo prop, that can be overwritten.

const globalSocket = new WebSocket('ws://127.0.0.1/ws');

<SocketProvider socket={globalSocket} bindTo='customEvent'>
    
    {/* becomes <CustomComponent socket={globalSocket} bindTo='customEvent'/> */}
    <CustomComponent/>
       
    {/* becomes <OtherComponent socket={globalSocket} bindTo='otherEvent'/> */}
    <CustomComponent bindTo='otherEvent' />
    
</SocketProvider>

withSocket

withSocket ables a component to be provided by SocketProvider.

export default withSocket(MyComponent)

EventListener

EventListener is the Component you want to extend whenever you want to receive updates for an event.

Overwrite its onData method to define what to do with the value.

class CustomerLogger extends EventListener {
    onData(value) {
        console.log('Customer has logged', value);
    }
}

// Usage
<CustomerLogger bindTo='customerHasLogged'/>

EventDispatcher

EventDispatcher is the Component you want to extend whenever you want to send event updates.

Invoke its onSubmit method to send a new event with its toSubmit prop value.

class LoginButton extends EventDispatcher {
    render() {
        return <button onClick={this.onSubmit}>Submit</button>
    }
}

// Usage
<LoginButton toSubmit={this.state.customerId} bindTo='customerHasLogged'/>

Credits

License

Unlicense. Please see License File for more information.

Current Tags

  • 0.2.3                                ...           latest (2 years ago)

14 Versions

  • 0.2.3                                ...           2 years ago
  • 0.2.2                                ...           2 years ago
  • 0.2.1                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.10                                ...           2 years ago
  • 0.1.8                                ...           2 years ago
  • 0.1.7                                ...           2 years ago
  • 0.1.6                                ...           2 years ago
  • 0.1.5                                ...           2 years ago
  • 0.1.4                                ...           2 years ago
  • 0.1.3                                ...           2 years ago
  • 0.1.2                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 16
Last Day 0
Last Week 15
Last Month 3
Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |