npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

io-event-reactor-plugin-support

v1.0.0-beta.4

Published

Supporting library for io-event-reactor module plugin development

Downloads

5

Readme

io-event-reactor-plugin-support

Supporting library for io-event-reactor plugin development.

NPM

If you want to develop a new MonitorPlugin or ReactorPlugin for io-event-reactor, you simply need to run npm install io-event-reactor-plugin-support in the root of your module folder. Once installed you can develop your plugin

MonitorPlugin

MonitorPlugins are responsible for listening for filesystem events and invoking a callback with io event information about the filesystem change. To create a plugin you simply need to export a class in your plugin that meets the following requirements. You can name the class whatever you want, but it should be the default thing exported by your plugin module.

(For an example MonitorPlugin implementation see: io-event-reactor-plugin-chokidar

MonitorPlugin class constructor() signature

MonitorPlugins only have to meet the below constructor signature requirement and properly invoke the provided callbacks as events occur in the filesystem. There are no other functions that need to be declared on the plugin class.

/**
* Constructor
*
* An io-event-reactor MonitorPlugin constructor signature
*
* @param reactorId - id of the IoReactor this Monitor plugin is bound to
* @param logFunction - a function to be used for logging w/ signature function(severity, origin, message)
* @param errorCallback - a function to be used for relaying any errors w/ signature function(message, sourceErrorObject)
*
* @param ioEventCallback - when a file/dir event occurs, invoke this function(eventType, fullPath, optionalFsStats, optionalExtraInfo)
*   - where 'eventType' is one of 'add', 'addDir', 'unlink', 'unlinkDir', or 'change'
*   - where 'fullPath' is the full path to the file/dir the event is for
*   - when available, "optionalFsStats" if not null, should be = https://nodejs.org/api/fs.html#fs_class_fs_stats
*   - when available, "optionalExtraInfo", varies by plugin
*
* @param initializedCallback - when this MonitorPlugin is full initialized, this callback should be invoked
*
* @param pluginConfig - Your custom configuration will be delivered in this object and the specification is for you to decide and document!
*
*/
constructor(reactorId, logFunction, errorCallback,
            ioEventCallback, initializedCallback, pluginConfig) {
    ....
}

ReactorPlugin

ReactorPlugins are responsible for reacting to an IoEvent by doing some action. What that action is, is up to you. To create a plugin you simply need to export a class in your plugin that meets the following requirements. You can name the class whatever you want, but it should be the default thing exported by your plugin module.

(For an example ReactorPlugin implementation see: io-event-reactor-plugin-mysql

At the top of your ReactorPlugin js file:

var IoEvent = require('io-event-reactor-plugin-support').IoEvent;
var ReactorResult = require('io-event-reactor-plugin-support').ReactorResult;

ReactorPlugin class constructor() signature

/**
* Constructor
*
* An io-event-reactor ReactorPlugin that reacts to IoEvents
*
* @param pluginId - identifier for this plugin
* @param reactorId - id of the IoReactor this Monitor plugin is bound to
* @param logFunction - a function to be used for logging w/ signature function(severity, origin, message)
* @param initializedCallback - when this ReactorPlugin is full initialized, this callback  function(reactorPluginId) should be invoked
*
* @param pluginConfig - Your custom configuration will be delivered in this object and the specification is for you to decide and document!
*
*/
constructor(pluginId, reactorId, logFunction,
            errorCallback, initializedCallback, pluginConfig) {
    ....
}

ReactorPlugin react() signature

The react(ioEvent) method is called when an IoEvent occurs that is applicable to this ReactorPlugin as configured in io-event-reactor. It should return a Promise that on both fulfill/reject returns an appropriately constructed ReactorResult object.

/**
* react(ioEvent) - core ReactorPlugin function
*
* This function is required on ReactorPlugin implementations
*
* @param ioEvent - IoEvent object to react to
* @return Promise - when fulfilled/rejected a ReactorResult object, on error the ReactorResult will contain the error
*
*/
react(ioEvent) {
    ....
}