add docs for eventWrapper

This commit is contained in:
Jonathan Rainville 2018-05-16 12:03:39 -04:00
parent 80c382557f
commit 441063dd10
2 changed files with 8 additions and 2 deletions

View File

@ -2,6 +2,13 @@ const uuid = require('uuid/v1');
const constants = require('../constants'); const constants = require('../constants');
class Events { class Events {
/**
* Constructs an event wrapper for processes.
* Handles sending an event message to the parent process and waiting for its response
* No need to create an instance of eventsWrapper for your own process, just extend ProcessWrapper
* Then, you an use `this.events.[on|request]` with the usual parameters you would use
*/
constructor() { constructor() {
this.subscribedEvents = {}; this.subscribedEvents = {};
this.listenToParentProcess(); this.listenToParentProcess();

View File

@ -15,10 +15,9 @@ class ProcessWrapper {
/** /**
* Class from which process extend. Should not be instantiated alone. * Class from which process extend. Should not be instantiated alone.
* Manages the log interception so that all console.* get sent back to the parent process * Manages the log interception so that all console.* get sent back to the parent process
* Also creates an Events instance. To use it, just do `this.event.[on|request]` * Also creates an Events instance. To use it, just do `this.events.[on|request]`
* *
* @param {Options} _options Nothing for now * @param {Options} _options Nothing for now
* @return {ProcessWrapper} Do not instantiate this alone. Use it to extend
*/ */
constructor(_options) { constructor(_options) {
this.interceptLogs(); this.interceptLogs();