Higher-Order-Function/Wrapper for "smartly" polling FaunaDB.
npm i faunadb-real-timeor
yarn add faunadb-real-timeconst { 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));👤 Taro [email protected]
- Website: cooksto.com
 - Twitter: @potato_potaro
 - Github: @potatopotaro
 - LinkedIn: @taro-woollett-chiba-25a802125
 
Give a ⭐️ if this project helped you!
This README was generated with ❤️ by readme-md-generator