Giter Site home page Giter Site logo

mikalv / react-pouchdb-changes Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scienceai/react-pouchdb-changes

0.0 2.0 0.0 132 KB

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

License: Apache License 2.0

JavaScript 100.00%

react-pouchdb-changes's Introduction

<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>

react-pouchdb-changes's People

Contributors

callahanchris avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.