reinbox

0.1.1 • Public • Published

reinbox

npm license CircleCI codecov

Declarative topic based notification UI manager for React (Native).
If you want to use reinbox with Redux, you can use reinbox-redux.

Install

npm install reinbox

Usage

import { Provider, Inbox, withPublish } from "reinbox";
 
const TOPIC = "test";
 
const Button = ({ publish }) => (
  <button onClick={() => publish(TOPIC, { id: "xxx", message: "notify me" })}>
    notify
  </button>
);
const PublishButton = withPublish(Button);
 
const App = () => (
  <Provider>
    <div>
      <PublishButton />
    </div>
    <Inbox topic={TOPIC}>
      {({ payload, dismiss }) =>
        payload && (
          <div>
            <span>{payload.message}</span>
            <button onClick={dismiss}>dismiss</button>
          </div>
        )
      }
    </Inbox>
  </Provider>
);

API

<Inbox />

<Inbox topic="test">
  {({ payload, dismiss }) =>
    payload && (
      <div>
        <span>{payload.message}</span>
        <button onClick={dismiss}>dismiss</button>
      </div>
    )
  }
</Inbox>
prop name required description
topic Yes Topic name you want to receive message
childrenn Yes Render notification message.
When there is no message, payload is null

Development

git clone git@github.com:Leko/reinbox.git
cd reinbox
npm i
npx lerna bootstrap

License

This package under MIT license.

Package Sidebar

Install

npm i reinbox

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

19 kB

Total Files

18

Last publish

Collaborators

  • lekoleko