faunadb-real-time

1.0.4 • Public • Published

Welcome to faunadb-real-time 👋

Version License: MIT Twitter: potato\_potaro

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.4
    0
    • latest

Version History

Package Sidebar

Install

npm i faunadb-real-time

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

10.6 kB

Total Files

6

Last publish

Collaborators

  • potatopotaro