buzzcasting-storage
TypeScript icon, indicating that this package has built-in type declarations

2.12.9 • Public • Published

BuzzCasting Storage

This is a wrapper class to use multiple storage options with BuzzCasting.

BuzzCasting Social Media Wall & Dataviz More info.

Currently supported are: Local Storage, Session Storage, IDB Keyval, Dexie, Window object

Features

Get started

Example call:

import BuzzcastingStorageManager, {
  IMessages,
  IQuery,
  IStorageManager,
} from 'buzzcasting-storage'

const options: IStorageManager = {
  app: 'my-subdomain',
  version: 'v4',
  token: 'meta',
  bearer: 'bearer_token',
  storage: 'dexie',
  moderation: 'none',
  beforeTime: null,
  delay: 0,
  period: 0,
}

const storageManager = new BuzzcastingStorageManager(options)

const query: IQuery = {
  type: 'messages',
  dashboard: 'dashboard_id',
  widget: 'widget_id',
}

const data: IMessages = storageManager.getMessages(query)

This will initiate a call to the buzzcasting backoffice to retrieve results

The Storage Manager will carry out the API call for the subscriber, and send out a BroadcastChannel on app to inform the subcriber that it can retrieve new data. The broadcast channel facilitates its incorporation in for example a Web Worker.

const broadcastChannel = new BroadcastChannel('my-subdomain')

broadcastChannel.onmessage = (messageEvent: MessageEvent) => {
  this.actions(messageEvent)
}

actions = (messageEvent: MessageEvent) => {
  switch (messageEvent.data.event) {
    case 'widget-update':
      // handle update
      this.widgetUpdated.emit(messageEvent.data.data)
      break
    default:
      // console.log('[storage]', messageEvent.data)
  }
}

Git Clone

git clone https://github.com/TouchFlows/buzzcasting-storage.git
cd buzzcasting-storage
pnpm install

Usage

The project contains the following scripts:

  • dev - Start the development server
  • build - Build for production
  • release - Generate changelog and npm publish
  • lint - Checks your code for any linting errors
  • test - Run all tests
  • test:watch - Run all tests with watch mode
  • test:coverage - Run all tests with code coverage report
  • prepare - Script for setting up husky hooks

License

This template was created under the MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i buzzcasting-storage

Weekly Downloads

3

Version

2.12.9

License

none

Unpacked Size

203 kB

Total Files

5

Last publish

Collaborators

  • marktamis