JavaScript SDK for ZetaPush


Keywords
zetapush, realtime, sdk, websocket, long-polling, cometd, javascript, nodejs
License
MIT
Install
npm install zetapush-js@3.3.2

Documentation

NPM version Document Build Status

ZetaPush JavaScript SDK

Install

From npm

npm install zetapush-js --save

From yarn

yarn add zetapush-js
import { Client, Authentication, services } from 'zetapush-js'

From CDN (unpkg recommended)

<script src="//unpkg.com/zetapush-js/dist/zetapush.min.js"></script>
const { Client, Authentication, services } = ZetaPush

Usage

// Create new ZetaPush Client
const client = new Client({
  sandboxId: '<YOUR-SANDBOX-ID>',
  authentication() {
    return Authentication.weak({
      token: null
    })
  }
})
// Create a Stack service
const service = client.createService({
  Type: services.Stack,
  listener: {
    list(message) {
      console.log('list callback', message)
    }
  }
})
// Add connection listener
client.onConnectionEstablished(() => {
  // Call service methods
  service.list({
    stack: '<YOUR-STACK-ID>'
  })
})
// Connect client to ZetaPush BaaS
client.connect()

Any questions?