Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rexxars/dumbo-ears
Small(ish) listener implementation for Sanity
https://github.com/rexxars/dumbo-ears
Last synced: 5 days ago
JSON representation
Small(ish) listener implementation for Sanity
- Host: GitHub
- URL: https://github.com/rexxars/dumbo-ears
- Owner: rexxars
- License: mit
- Created: 2018-12-06T13:11:54.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-06T14:24:56.000Z (almost 6 years ago)
- Last Synced: 2024-10-11T07:13:23.622Z (27 days ago)
- Language: JavaScript
- Size: 105 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-sanity - `dumbo-ears` - Small(ish) listener implementation for Sanity. Useful if you only need listeners. (Related projects / Studio Inspiration)
README
# dumbo-ears
[![npm version](https://img.shields.io/npm/v/dumbo-ears.svg?style=flat-square)](http://browsenpm.org/package/dumbo-ears)[![Build Status](https://img.shields.io/travis/rexxars/dumbo-ears/master.svg?style=flat-square)](https://travis-ci.org/rexxars/dumbo-ears)
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
```bash
npm install --save dumbo-ears
```## Usage
```js
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](https://espen.codes/)