README
Node soct-example-service
Example service class for soct. This module is intended to be used as an example class to use with soct. It has some simple properties, a few methods, and an event to which one may subscribe.
Install
npm i -s soct-example-service
Usage
const ExampleService = require('soct-example-service');
const run = async () => {
const example = new ExampleService();
/************************************************/
let lastResult;
// the newResult function returns the sum of 2 numbers.
lastResult = exampleService.newResult(1,2); // => 3
// the lastResult property holds the last result
lastResult = exampleService.lastResult; // => 3
// the lastResult property can also be written to...because 'why not...'
exampleService.lastResult = 4; // => 4
/************************************************/
let running;
// the running property has the state of whether the service is running
running = example.running; // => false
// the start function will start the service
example.start();
running = example.running; // => true
// the stop function will stop the service
example.stop();
running = example.running; // => false;
/************************************************/
// the update event will emit the lastResult on random intervals between 1 and 2 seconds.
example.on('update', res => console.log(res));
example.start();
}
run;
Class
Properties
- running (bool)
- lastResult (number)
Methods
- newResult(a,b)
- start()
- stop()
Events
- update (emits 'lastResult');