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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ng-commander

v1.2.1

Published

Command pattern for Angular applications

Downloads

291

Readme

NG Commander

NG Commander is a service designed to manage and execute commands in an Angular application using RxJS for reactive programming. It provides a robust framework for handling command execution, retries, and error management.

Features

  • Command Execution: Execute commands asynchronously and manage their state.
  • Error Handling: Automatically retry commands that fail, with configurable retry limits.
  • State Management: Track the state of command execution (IDLE, EXECUTING, DONE, ERROR).
  • Reactive Programming: Utilize RxJS for reactive command management.

Installation

To install NG Commander, run the following command:

npm install ng-commander

Usage

Import the Service

Import the Commander service into your Angular module or component:

import { Commander } from "ng-commander";

Initialize the Service

Initialize the service with a configuration object:

constructor(private commander: Commander) {
  this.commander.init({
    error: {
      maxNumberOfRetries: 3,
    },
  });
}

Add Commands

Add commands to the commander for execution:

const command: Command<any> = {
  execute: () => {
    // Command execution logic
    return of("Command executed successfully");
  },
};

this.commander.addCommand(command);

Handle Command Events

Subscribe to command events to handle execution results:

this.commander.commands$.subscribe((commands) => {
  console.log("Commands:", commands);
});

this.commander.commandsDone$.subscribe((doneCommands) => {
  console.log("Done Commands:", doneCommands);
});

this.commander.commandsInError$.subscribe((errorCommands) => {
  console.log("Error Commands:", errorCommands);
});

this.commander.commandsDead$.subscribe((deadCommands) => {
  console.log("Dead Commands:", deadCommands);
});

this.commander.state$.subscribe((state) => {
  console.log("State:", state);
});

API

Methods

  • init(configuration: CommanderConfiguration): Initialize the commander with a configuration.
  • addCommand<C>(command: Command<C>): Add a command to the commander.
  • replayCommandsInError(): Replay commands that are in error.
  • getCommands(type: CommandsType): Get commands of a specific type.
  • getState(): Get the current state of the commander.
  • stop(): Stop the commander.

Observables

  • commands$: Observable of all commands.
  • commandsDone$: Observable of commands that have been executed successfully.
  • commandsInError$: Observable of commands that have encountered errors.
  • commandsDead$: Observable of commands that have been marked as dead.
  • state$: Observable of the current state of the commander.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

License

This project is licensed under the MIT License.