0.2.2 • Published 10 years ago

phineas-sdk v0.2.2

Weekly downloads
-
License
ISC
Repository
-
Last release
10 years ago

Phineas Javascript SDK

Installation (browserify/webpack)

npm install --save phineas-sdk

or standalone build in dist/standalone.js which makes Phineas available globally.

Usage

const Phineas = require('phineas-sdk')

// appID and secret available from web UI 
const app = Phineas.inititalize({
	appID: <app_id>
  secret: <secret>
})

// 'Users' is the name of DynamoDB table
const UserTable = app.table('Users')

const username = 'alice'
const subscription = UserTable.subscribe('getUserInfo', username, function (err, data) {
  if(err) {
    throw err
  } 

  console.log(data)
})


subscription
  .on('INSERT', function (event) {
    console.log('new item added', event.newItem)
  })
  .on('MODIFY', function (e) {
    console.log('item modified', e.oldItem, e.newItem)
  })
  .on('REMOVE', function (e) {
    console.log('item deleted', e.oldItem)
  })

// unsubscribe
UserTable.unsubscribe('getUserInfo', username)

Instead of subscribing to a query, you can also make a one time call using the call callOnce() method.

const UserTable = app.table('Users')

UserTable.callOnce('getUserInfo', username, function (err, data) {
  if(err) {
    throw err
  } 

  console.log(data)
})
0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.1-3

10 years ago

0.0.1-2

10 years ago

0.0.1-1

10 years ago