Skip to content

electron-reactive-event / CLI / Introduction

Introduction to the CLI

Purpose

This article describes the helper package electron-reactive-event-cli. Using this package is optional, and automates writing boilerplate code needed to register your event declarations with your registrar interfaces.

Motivation

It is expected that most developers will want their event declarations to live alongside logic corresponding to these events, i.e., not in a single module that pulls in types from modules scattered throughout their codebase.

Event declarations are grouped by registrar interfaces, and these registrar interfaces are what the developer passes to the factories provided by this package.

The issue presented by the above is that defining event declarations should be decentralized (in most cases), but a central definition (i.e., registrar interfaces) is required for electron-reactive-event to ingest them.

Fortunately, TypeScript allows for interfaces to be extended via module augmentation . This feature allows for the registrar interfaces in your project to be supplemented with your event declarations, regardless of where they are in your project.

However, declare module blocks are lengthy, and are tedious to write for every module in which an event declaration is defined.

To address this, a CLI package electron-reactive-event-cli was created, which writes these declare module blocks for you. They are written to a single module, which can exist anywhere in your project that is recognized by your project's TSConfig's include property .

Getting Started

Follow the steps in the Project Setup article to perform the minimum setup needed to run the interactive wizard provided by the setup command.

If your project already uses electron-reactive-event, then you have likely done everything in the Project Setup article. If this is the case, then you may skip ahead to the setup Command article.

The interactive wizard provided by the setup command will notify you if a prerequisite step has not been completed.

References

TypeScript: Documentation - Declaration Merging

TypeScript: TSConfig Reference - Docs on every TSConfig option § Include - include