1.0.4 • Published 4 years ago

faunadb-real-time v1.0.4

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Higher-Order-Function/Wrapper for "smartly" polling FaunaDB.

Install

npm i faunadb-real-time

or

yarn add faunadb-real-time

How to Use

const { withRealTimeMethods } = require('faunabd-real-time');
const { Client } = require('faunadb');

const client = withRealTimeMethods(new Client({
  secret: '<FAUNA_SECRET>'
}));

// Index must return a FaunaDB TS as the first element.
// Additionally, returning the Document's Ref afterwards...
// is useful for reading the entire Document, after mapping (as seen below).
const subscribable = client
  .livePaginate(
    q.Match(q.Index("<INDEX_RETURNING_TS_FIRST>")),
    {}, // param_object for FQL's Paginate
    { // default options for specifying polling frequencies (in milliseconds)
      activeMs: 5000,
      passiveMs: 10000,
      passiveAfter: 10000
    }
  )
  .map((arr) => q.Get(q.Select([1], arr)))
  
const unsubscribeA = subscribable
  .subscribe(data => console.log('subscription A', data));

const unsubscribeB = subscribable
  .subscribe(data => console.log('subscription B', data));

Author

👤 Taro taro.s.chiba@gmail.com

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago