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

@ngx-kit/store

v1.0.0-beta.1

Published

ngx-kit - store

Downloads

4

Readme

Angular Store

Immutable store for Angular with fancy decorators.

Currently in a deep beta!

Install

npm install @ngx-kit/store immutable --save

Usage

Provide immutable

Angular-cli

Add this row to .angular-cli.json:

"scripts": [
  ...
  "../node_modules/immutable/dist/immutable.js",
]

Import Module

Import provides service with scope app and initial state {started: false}

@NgModule({
  imports: [
    ...
    StoreModule.provide('app', {started: false}),
  ],
  ...

Create Actions

TBD

Actions Decorators

  • SetProp(keyPath: string[])
  • UpdateProp(keyPath: string[])
  • SetCollectionItem(keyPath: string[], indexKey = 'id')
  • UpdateCollectionItem(keyPath: string[], indexKey = 'id')
  • DeleteCollectionItem(keyPath: string[], indexKey = 'id')
  • UpdateCollection(keyPath: string[], indexKey = 'id')

Create Selectors

TDB

Selectors Decorators

  • SelectProp(keyPath: string[])
  • SelectPropCombined(keyPaths: string[][], indexKey = 'id')
  • SelectCollectionKeys(keyPath: string[], indexKey = 'id')
  • SelectCollectionItem(keyPath: string[], indexKey = 'id')

Dispatch

constructor(private store: Store) {
}
...
someMethod(value) {
  this.store.dispatch(ActionsClass.setValue(value));
}

Get Stream

constructor(private store: Store) {
}
...
someMethod() {
  this.store.stream(SelectorsClass.value()).subsribe(value => {
  });
}

Get Value

constructor(private store: Store) {
}
...
someMethod() {
  const value = this.store.value(SelectorsClass.value();
}

Examples

Actions

...

export class AuthActions {

  @SetProp(['account'])
  static setAccount(account: CompanyAccountModel) {
    return account;
  }

  @SetProp(['isAuth'])
  static setIsAuth(isAuth: boolean) {
    return isAuth;
  }

  @SetProp(['account', 'live'])
  static setLive(live: boolean) {
    return live;
  }
  
  @UpdateCollectionItem(['clients'])
  static assignClient(changes: {id: number, assignedTo: number}) {
    return (client) => {
      // Here you gets client model from store and should return updated value.
      // immutable will be provided by Immutable.js
      return Object.assign(client, {assignedTo: changes.assignedTo, archived: false});
    };
  }
  
  ...
}

Selectors

...
export class AuthSelectors {

  @SelectProp(['isAuth'])
  static isAuth() {
  }

  @SelectProp(['account', 'live'])
  static live() {
  }

  @SelectProp(['account'])
  static account() {
  }

  @SelectProp(['account', 'owner'])
  static isOwner() {
  }
  
  @SelectProp(['clients'])
  static archivedClients() {
    return (clients: ClientModel[]) => {
      return clients.filter(client => client.archived && !client.blocked);
    }
  }

  @SelectPropCombined([
    ['clients'],
    ['messages'],
  ])
  static clientWithMessages(clientId: number) {
    return (data) => {
      let [clients, messages] = data;
      return {
        client: clients.find(x => x.id == clientId),
        messages: messages.filter(x => x.clientId == clientId),
      }
    };
  }

  @SelectCollectionItem(['clients'])
  static client(id: number) {
  }

  @SelectCollectionItem(['tmpMessages'], 'clientId')
  static tmpMessage(clientId: number) {
    return (tmpMessage: TmpMessageModel) => {
      return tmpMessage ? tmpMessage.text : '';
    };
  }
}