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

angular-spawn-x

v1.0.1

Published

Angular connector for spawn-x. (Reactive management for javaScript applications)

Readme

angular-spawn-x

Angular connector for spawn-x (AoT supports).

install

With npm:

npm install angular-spawn-x --save

With yarn:

yarn add angular-spawn-x

Usage

index.html

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>App</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
  <app-root>Loading...</app-root>
</body>
</html>

main.ts

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule);

Add the ngSpawnModule in dependencies

app/app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { NgSpawnModule } from 'angular-spawn-x';

import { configureStore } from './store';
import { AppComponent } from './app.component';
import { PresenterComponent } from './components/presenter.component';
import { UserActions } from './actions/user';


@NgModule({
  declarations: [
    AppComponent,
    PresenterComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    NgSpawnModule.forRoot(configureStore)
  ],
  providers: [UserActions],
  bootstrap: [AppComponent]
})
export class AppModule { }

Configure store with standarts functions createStore and addInterceptor

app/store/index.ts

import { createStore, addInterceptor } from 'angular-spawn-x';

const initialState = {
  users: [],
  some: {
    text: 'Hello World'
  },
  parent: {
    child: 'I am child'
  }
};

function logger(store) {
  return next => action => {
    next(action);
    console.log('action: ', action.type + ' -> ', action.data);
  }
}

export function configureStore() {
  return createStore(initialState, addInterceptor(logger));
}

Inject ngSpawn into your app, and use select, detect, reject and update methods

app/actions/user.ts

import { Injectable } from '@angular/core';
import { NgSpawn } from 'angular-spawn-x';


@Injectable()
export class UserActions {
  constructor(private ngSpawn: NgSpawn) {}

  addUser = user => {
    this.ngSpawn.update('users', {
      data: this.ngSpawn.select('users').concat(user),
      type: 'ADD_NEW_USER'
    });
  }
}

For subscribe or unsubscribe on data use connect and disconnect methods like below

app/app.component.ts

import {
  Component,
  OnInit,
  OnDestroy,
  ChangeDetectionStrategy
} from '@angular/core';
import { NgSpawn } from 'angular-spawn-x';
import { UserActions } from '../actions/user';


@Component({
  selector: 'app-root',
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <app-presenter
      [users]="users"
      [text]="text"
      [data]="data"
      (addUser)="addUserHandler($event)">
    </app-presenter>
  `
})
export class AppComponent implements OnInit, OnDestroy {

  constructor(
    private ngSpawn: NgSpawn,
    private userActions: UserActions
  ){}

  ngOnInit() {
    //selection from store
    const selection = {
      users: 'users',
      text: 'some.text',
      data: ['parent.child', state => state.parent.child]
    };
    //connect to store
    this.ngSpawn.connect(selection)(this);
  }

  ngOnDestroy() {
    //disconnect from store
    this.ngSpawn.disconnect(this);
  }

  addUserHandler(user) {
    this.userActions.addUser(user);
  }
}

app/components/presenter.component.ts

import {
  Component,
  OnInit,
  Input,
  Output,
  EventEmitter,
  ChangeDetectionStrategy
 } from '@angular/core';


@Component({
  selector: 'app-presenter',
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <div>
      <h1>User List</h1>
      <ul>
        <li *ngFor="let user of users">{{ user.name }} | {{ user.age }}</li>
      </ul>
      <form (submit)=handleSubmit($event)>
        <input type="text" name="name"/>
        <input type="number" name="age"/>
        <button type="submit">Add New User</button>
      </form>
    </div>
  `
})
export class PresenterComponent implements OnInit {
  @Input() users: any;
  @Input() text: string;
  @Input() data: string;
  @Output() addUser = new EventEmitter<any>();

  constructor() {}

  ngOnInit() {}

   handleSubmit = ev => {
    console.log('some text from state: ', this.text);
    console.log('some data from state: ', this.data);

    this.addUser.emit({
      name: ev.target.name.value,
      age: ev.target.age.value
    })

    ev.target.name.value = '';
    ev.target.age.value = '';
  }
}

LICENSE

MIT © Alex Plex