1.0.0 • Published 5 years ago

dumbo-ears v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

dumbo-ears

npm versionBuild Status

Small(ish) listener implementation for Sanity. Useful if you only need listeners.

Targets

  • Node.js >= 6
  • Modern(ish) browsers (IE >= 11, Chrome, Safari, Firefox etc)

Installation

npm install --save dumbo-ears

Usage

const DumboEars = require('dumbo-ears')

// Instantiate a client
const client = new DumboEars({
  projectId: 'myProjectId',
  dataset: 'myDataset',
  token: 'moop', // optional
})

// Listen for changes on the given query
const subscription = client
  .listen(
    '*[_type == $someType]',
    {someType: 'article'},
    {includePreviousRevision: false}
  )
  .subscribe(mutation => console.log(mutation))

// Unsubscribe from events after 30 seconds
setTimeout(() => {
  subscription.unsubscribe()
}, 30 * 1000)

UMD bundle

You can load this module as a UMD-bundle from unpkg - https://unpkg.com/dumbo-ears
If used in a global browser context, it will be available as window.DumboEars

License

MIT © Espen Hovlandsdal