2.4.0 • Published 6 years ago

@bitrefill/react-pusher v2.4.0

Weekly downloads
86
License
-
Repository
github
Last release
6 years ago

react-pusher

// Use the pusher component

import Pusher from '@bitrefill/react-pusher';

function SomeComponent() {
  return (
    <Pusher
      apiKey={PUSHER_API_KEY}
      opts={{additional: 'options'}}
      channel="channel"
      events={["event"]}
      onUpdate={(event, payload) => {
        // ...
      }}
    />
  )
}
// Load the component async

import React from 'react';
import Loadable from 'react-loadable';

const LoadablePusher = Loadable({
  loader: () => import('@bitrefill/react-pusher'),
  loading: null,
});

function SomeComponent() {
  return (
    <LoadablePusher
      apiKey={PUSHER_API_KEY}
      opts={{ additional: 'options' }}
      channel="channel"
      events={["event"]}
      onUpdate={(event, payload) => {
        // ...
      }}
    />
  )
}
// Access the pusher instance

import { getPusherClient } from '@bitrefill/react-pusher';

const pusher = getPusherClient(PUSHER_API_KEY, { additional: 'options' });
const channel = pusher.subscribe('someChannel');
// ...
// Access the pusher instance async

import('@bitrefill/react-pusher').then(({ getPusherClient }) => {
  const pusher = getPusherClient(PUSHER_API_KEY, { additional: 'options' });
  const channel = pusher.subscribe('someChannel');
  // ...
})
// ...

PropTypes

NameType
apiKeyPropTypes.string.isRequired
optsPropTypes.object
channelPropTypes.string.isRequired
eventsPropTypes.array.isRequired
onUpdatePropTypes.func.isRequired
2.4.0

6 years ago

2.3.2

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago