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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ngx-wcore

v1.3.1

Published

This library allows for easy data store and event management.

Readme

Wcore

This library allows for easy data store and event management.

install

npm i ngx-wcore

Configuration

First import the CoreModule into your app.module.ts file

imports: [ CoreModule ],

Then create your custom WorkerService to your specifications. Here a minimal example :

import {Injectable} from '@angular/core';
import {WorkerDataClass, WorkerServicePrototype} from 'ngx-wcore';
import {RootDataClass} from '../Models/root-data-class';

@Injectable({
  providedIn: 'root'
})
@WorkerDataClass(new RootDataClass()) // VERY important
export class WorkerService extends WorkerServicePrototype { // VERY important


  constructor() {
    super();
  }

  data(): RootDataClass { // VERY important
    return super.data() as RootDataClass;
  }

}

The Root DataClass can be whatever Object you want it to be :).

Once your Service is up and running you can configure the CoreService and set up your events.

Here a small example:

import {Component} from '@angular/core';
import {WorkerService} from './services/worker.service';
import {TestService} from './services/test.service';
import {SystemActions, WCoreService} from 'ngx-wcore';


@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {

  constructor(
    public w: WorkerService,
    private core: WCoreService
  ) {

    this.core.initCore([
        {
          name: 'TestService', // your service ID -> only used for debugging purposes. you can put any kind of string there
          service: TestService, // the service class. Must extend AbstractService
          initOn: SystemActions.init
          // and here the Event that should start the Service. 
          // By default it is the init event right at the startup of the app
        }
      ],
      this.w);

    LOG.debug.log('DATASET', this.w.data()); // Here you can access all your data from the store
    LOG.debug.log('available services', this.w.availableServices); // and here you can checkout all your available services
  }
}

You are now ready to use the service however you like :)

Create custom Events

Here an example of how to create a custom Event class

import {ActionPrototype} from 'ngx-wcore';


export class A<T, K> extends ActionPrototype<T, K> {

  // Here you can add as many events as you like with any values but they must be static and readonly
  static readonly localEvent = new A<number, Error>('custom Event');
  static readonly eventA = new A<number, Error>('custom Event');
  static readonly eventB = new A<number, Error>('custom Event');

  constructor(
    description: string,
    protected readonly payload: T = null,
    public readonly error: K = null
  ) {
    super(description, payload, error);
    this.init(this, A);
  }
}

An action takes 3 kinds of parameters

  • the payload : What type of data is associated to the event
  • the error : What error does the event trigger
  • the description : What does the event do -> For debugging purposes

Use the WorkerService

Anf here multiple examples of how to use the workerservice

With actions

Trigger actions with payload or without

this.w.trigger(A.eventA, 8);
this.w.trigger(A.eventB);

Subscribe to actions and use their payload. Also access the datasStore

this.w.on(A.eventA).pipe(
  tap((payload) => {
    this.w.data().test.counterA = payload;
  })).subscribe();