Skip to content

huang2002/hele-hbus

Repository files navigation

hele-hbus

HEle bindings for HBus.

Example

const { Bus, Subscription } = HEle, // exported components
    busName = 'bus'; // default: HEle.defaultBusName

class PublishButton extends HEle.Component {
    constructor(props, context) {
        super(props, context);
        this.publish = this.publish.bind(this);
    }
    publish() {
        const { [busName]: bus } = this.context;
        bus.publish(new HBus.Action('ACTION_TYPE', PAYLOAD));
    }
    render() {
        return <button onclick={this.publish}>Publish an action</button>;
    }
}

HEle.render(
    <Bus name={busName} processor={PROCESSOR} defaultState={DEFAULT_STATE}>
        <Subscription bus={busName}>
            {state => (
                <p>Current state: {state}</p>
            )}
        </Subscription>
        <Subscription bus={busName} prop="PROP_NAME">
            {prop => (
                <p>Current prop: {prop}</p>
            )}
        </Subscription>
        <PublishButton />
    </Bus>,
    document.getElementById('root')
);

APIs

The example above has shown how to use this lib. If you want the detailed API reference, please read the source files in src or the type declaration files in typings.

Changelog

See CHANGELOG.md

About

HEle bindings for HBus.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published