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

@alma3lol/reactive-process

v2.0.3

Published

An npm process moduling package made with RxJS

Downloads

10

Readme

ReactiveProcess

An npm process moduling package made with RxJS

Installation

Using npm:
npm install --save @alma3lol/reactive-process
Using yarn:
yarn add @alma3lol/reactive-process

Usage

Simple enough:

import { ReactiveProcess } from '@alma3lol/reactive-process';

const ls = ReactiveProcess.create("ls", ["-lAsh"], {
	next: (cast) => { /* handle cast */ },
	complete: () => { /* handle complete */ }
});

cast Object

The cast object is just an object with 1 of 3 properties: stdout, stderr or status.

Stdout: This is the output of the process.
Stderr: This is the error stream of the process.
Status: This is the status of the process. It can be either Running or Stopped.

Other process properties & functions

Properties

The process has other properties including all RxJS Subject's and the following:

  • cmd: The executed command.
  • args: Arguments passwed to the command.
  • process: The core process.
  • pid: The process ID.
  • exitCode: The process exit code.

Functions

Functions include all RxJS Subject's and start function:

  • start: A function to start the process. (see blow for more details)

Usage with MobX

Reactive Process is a actually a class that extends RxJS' Subject, which can be treated as a Model.
The base class name for Reactive Process is Model and the return value of ReactiveProcess.create(...) is an instance of Model

In code, it should look as follows:

import { observable } from 'mobx';
import { ReactiveProcess } from '@alma3lol/reactive-process';

class Processes {
	@observable processes: ReactiveProcess.Model[] = [];
	addProcess(process: ReactiveProcess.Model) {
		this.processes.push(process);
	}
}

Model

The Model class is an extend of RxJS' Subject and inherts all of it's functionality.
You can subscribe to it manually whenever/wherever needed.

ReactiveProcess.create vs ReactiveProcess.Model

There's a small difference between .create & .Model in ReactiveProcess: Using .Model doesn't start the process upon initiation.

To start the process when using .Model, you need to call Model.start:

const model = new ReactiveProcess.Model(...);
model.start();
/* OR */
const model = new ReactiveProcess.Model(...).start();

Start

This function has the following call signature:

() => this

It returns this which is the model's instance itself.

GOALS

  • Add support for deamon process
  • Add stdin support