{"id":17132174,"url":"https://github.com/bitsofinfo/io-event-reactor-plugin-support","last_synced_at":"2025-03-24T05:18:42.373Z","repository":{"id":57275629,"uuid":"60559842","full_name":"bitsofinfo/io-event-reactor-plugin-support","owner":"bitsofinfo","description":"Plugin development supporting library for: io-event-reactor ","archived":false,"fork":false,"pushed_at":"2017-03-01T22:25:05.000Z","size":6,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-02T09:41:39.968Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/bitsofinfo/io-event-reactor","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitsofinfo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-06T20:48:06.000Z","updated_at":"2017-03-10T22:13:59.000Z","dependencies_parsed_at":"2022-09-15T19:10:28.406Z","dependency_job_id":null,"html_url":"https://github.com/bitsofinfo/io-event-reactor-plugin-support","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitsofinfo%2Fio-event-reactor-plugin-support","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitsofinfo%2Fio-event-reactor-plugin-support/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitsofinfo%2Fio-event-reactor-plugin-support/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitsofinfo%2Fio-event-reactor-plugin-support/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitsofinfo","download_url":"https://codeload.github.com/bitsofinfo/io-event-reactor-plugin-support/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245212311,"owners_count":20578443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T19:26:16.217Z","updated_at":"2025-03-24T05:18:42.349Z","avatar_url":"https://github.com/bitsofinfo.png","language":"JavaScript","readme":"# io-event-reactor-plugin-support\n\nSupporting library for [io-event-reactor](https://github.com/bitsofinfo/io-event-reactor) plugin development.\n\n[![NPM](https://nodei.co/npm/io-event-reactor-plugin-support.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/io-event-reactor-plugin-support/)\n\nIf you want to develop a new `MonitorPlugin` or `ReactorPlugin` for [io-event-reactor](https://github.com/bitsofinfo/io-event-reactor), you simply\nneed to run `npm install io-event-reactor-plugin-support` in the root of your module folder. Once installed you can develop your plugin\n\n## MonitorPlugin\n\nMonitorPlugins are responsible for listening for filesystem events and invoking a callback with io event information about the\nfilesystem change. To create a plugin you simply need to export a `class` in your plugin that meets the following requirements.\nYou can name the class whatever you want, but it should be the default thing exported by your plugin module.\n\n(For an example MonitorPlugin implementation see: [io-event-reactor-plugin-chokidar](https://github.com/bitsofinfo/io-event-reactor-plugin-chokidar)\n\n#### MonitorPlugin class constructor() signature\n\nMonitorPlugins only have to meet the below constructor signature requirement and\nproperly invoke the provided callbacks as events occur in the filesystem. There are no\nother functions that need to be declared on the plugin class.\n\n```\n/**\n* Constructor\n*\n* An io-event-reactor MonitorPlugin constructor signature\n*\n* @param reactorId - id of the IoReactor this Monitor plugin is bound to\n* @param logFunction - a function to be used for logging w/ signature function(severity, origin, message)\n* @param errorCallback - a function to be used for relaying any errors w/ signature function(message, sourceErrorObject)\n*\n* @param ioEventCallback - when a file/dir event occurs, invoke this function(eventType, fullPath, optionalFsStats, optionalExtraInfo)\n*   - where 'eventType' is one of 'add', 'addDir', 'unlink', 'unlinkDir', or 'change'\n*   - where 'fullPath' is the full path to the file/dir the event is for\n*   - when available, \"optionalFsStats\" if not null, should be = https://nodejs.org/api/fs.html#fs_class_fs_stats\n*   - when available, \"optionalExtraInfo\", varies by plugin\n*\n* @param initializedCallback - when this MonitorPlugin is full initialized, this callback should be invoked\n*\n* @param pluginConfig - Your custom configuration will be delivered in this object and the specification is for you to decide and document!\n*\n*/\nconstructor(reactorId, logFunction, errorCallback,\n            ioEventCallback, initializedCallback, pluginConfig) {\n    ....\n}\n```\n\n## ReactorPlugin\n\nReactorPlugins are responsible for reacting to an IoEvent by doing some action.\nWhat 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.\nYou can name the class whatever you want, but it should be the default thing exported by your plugin module.\n\n(For an example ReactorPlugin implementation see: [io-event-reactor-plugin-mysql](https://github.com/bitsofinfo/io-event-reactor-plugin-mysql)\n\nAt the top of your ReactorPlugin js file:\n```\nvar IoEvent = require('io-event-reactor-plugin-support').IoEvent;\nvar ReactorResult = require('io-event-reactor-plugin-support').ReactorResult;\n```\n\n#### ReactorPlugin class constructor() signature\n\n```\n/**\n* Constructor\n*\n* An io-event-reactor ReactorPlugin that reacts to IoEvents\n*\n* @param pluginId - identifier for this plugin\n* @param reactorId - id of the IoReactor this Monitor plugin is bound to\n* @param logFunction - a function to be used for logging w/ signature function(severity, origin, message)\n* @param initializedCallback - when this ReactorPlugin is full initialized, this callback  function(reactorPluginId) should be invoked\n*\n* @param pluginConfig - Your custom configuration will be delivered in this object and the specification is for you to decide and document!\n*\n*/\nconstructor(pluginId, reactorId, logFunction,\n            errorCallback, initializedCallback, pluginConfig) {\n    ....\n}\n```\n\n#### ReactorPlugin react() signature\n\nThe `react(ioEvent)` method is called when an IoEvent occurs that is applicable to this ReactorPlugin as configured in `io-event-reactor`.\nIt should return a `Promise` that on both fulfill/reject returns an appropriately constructed `ReactorResult` object.\n\n```\n/**\n* react(ioEvent) - core ReactorPlugin function\n*\n* This function is required on ReactorPlugin implementations\n*\n* @param ioEvent - IoEvent object to react to\n* @return Promise - when fulfilled/rejected a ReactorResult object, on error the ReactorResult will contain the error\n*\n*/\nreact(ioEvent) {\n    ....\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitsofinfo%2Fio-event-reactor-plugin-support","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitsofinfo%2Fio-event-reactor-plugin-support","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitsofinfo%2Fio-event-reactor-plugin-support/lists"}