@vincit/rematch-pubnub
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

Rematch-PubNub

PubNub-Redux SDK plugin for Rematch.

The PubNub Redux SDK offers a data management framework that listens to realtime events generated by the PubNub network to update the view inside your application. And of course, your data can coexist with PubNub-defined data.

Install

npm install @vincit/rematch-pubnub
yarn add @vincit/rematch-pubnub

Setup

import createRematchPubnub from '@vincit/rematch-pubnub'

const pubnubPlugin = createRematchPubnub({
  publishKey: 'publishKey',
  subscribeKey: 'subscribeKey',
  uuid: 'uuid',
})

init({
  plugins: [pubnubPlugin],
})

PubNubProvider

The PubNubProvider makes available a PubNub client instance to a React component tree.

import { getPubnubInstance } from '@vincit/rematch-pubnub'
import { PubNubProvider } from 'pubnub-react'

const pubnub = getPubnubInstance()

const Root = () => (
  <PubNubProvider client={pubnub}>
    <App />
  </PubNubProvider>
)

TypeScript Support

import { PubnubState } from '@vincit/rematch-pubnub'

export type iRootState = RematchRootState<typeof models> & PubnubState

Manually setting the Pubnub client instance

store.ts

import createRematchPubnub from '@vincit/rematch-pubnub'

const pubnubPlugin = createRematchPubnub()

init({
  plugins: [pubnubPlugin],
})

app.tsx

import { setPubnubInstance } from '@vincit/rematch-pubnub'
import { PubNubProvider } from 'pubnub-react'

const App = () => {
  const pubnub = new Pubnub({
    publishKey: 'publishKey',
    subscribeKey: 'subscribeKey',
    uuid: 'uuid',
  })

  setPubnubInstance(pubnub)

  return (
    <PubNubProvider client={pubnub}>
      <App />
    </PubNubProvider>
  )
}

Usage

See pubnub-redux docs

Package Sidebar

Install

npm i @vincit/rematch-pubnub

Weekly Downloads

0

Version

1.2.1

License

MIT

Unpacked Size

23.6 kB

Total Files

9

Last publish

Collaborators

  • vabanagas