2.0.0 • Published 6 years ago

signalk-plugin-state v2.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Just playing around with different options that could be added to the app object to help developer manage plugin state. Hope to add to the server.

Usage

const { wrapPlugin } = require('signalk-plugin-state')

function initPlugin(app) {
  return {
    id: 'sk-example',
    name: 'SK Example Plugin',
    description: 'Something that does a think with SK.',
    schema,
    start: buildStart(app),
    stop: buildStop(app),
    // uiSchema,
  }
}

module.exports = wrapPlugin(initPlugin)

API

app.ref

Object with the following methods:

  • addInterval(id, func, seconds) - Automatically cleared when plugin.stop() is called.
  • set(id, func) - Set references to methods or values.
  • get(id) - Returns method or value.
  • invoke(id) - Calls reference method.
  • clear() - Removes all references. Does not unsubscribe or similar. Just removes any saved refs.

Helpers

  • Any function added via app.ref.set(['onClose', id]) will be called on plugin.close() automatically.
  • Validation of plugin props against schema before sending to plugin.
  • Calls app.ref.clear() on plugin.close().
2.0.0

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago