Skip to content

React component middleware for listening to the changes feed from CouchDB or PouchDB

License

Notifications You must be signed in to change notification settings

mikalv/react-pouchdb-changes

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

<PouchDBChanges />

Build Status

Install

npm install react-pouchdb-changes

Using the Component

import PouchDBChanges from 'react-pouchdb-changes';

API

  • dbUrl: String: Required. The URL of the remote CouchDB or the name of the local PouchDB to listen to changes from.
  • dbOpts: Object: Optional. The options that will be passed when connecting to the remote DB. Defaults to an empty object. See the PouchDB Docs for more details.
  • changesOpts: Object: Optional. The options that determine how to consume the changes feed. Defaults to an empty object. Note that if {live: true} is passed here the changes feed is continuously polled until the changes feed is canceled or the component unmounts; otherwise the operation is atomic. See the PouchDB Docs for more details.
  • onChange: Function: Optional. Called when the change event is fired from the changes feed.
  • onComplete: Function: Optional. Called when the complete event is fired from the changes feed.
  • onError: Function: Optional. Called when the error event is fired from the changes feed.
  • onPaused: Function: Optional. Called when the paused event is fired from the changes feed.
  • children: Any: Optional. The children that will be rendered by this component. The PouchDBChanges component does not take responsibility for rendering any UI, so it can be plugged in at the root of your application or anywhere it makes sense to have access to the changes feed.

Example

<PouchDBChanges
  dbUrl='http://localhost:5984/mydb'
  changesOpts={{
    since: 'now',
    live: true,
    include_docs: true
  }}
  onChange={change => this.setState({ latestDoc: change.doc })}
  onError={err => this.handleError(err)}
>
  <App>
    ...
  </App>
</PouchDBChanges>

About

React component middleware for listening to the changes feed from CouchDB or PouchDB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%