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

@softwarepioniere/ngrx-manager

v0.0.79

Published

### Installation

Downloads

51

Readme

HOW TO USE

Installation

Run

npm i @angular/common@^6.0.0-rc.0 || ^6.0.0 --save
npm i @angular/core@^6.0.0-rc.0 || ^6.0.0 --save
npm i @ngrx/[email protected] --save
npm i @ngrx/[email protected] --save
npm i @ngrx/[email protected] --save
npm i [email protected] --save
npm i [email protected] --save
npm i [email protected] --save
npm i [email protected] --save
npm i @ngx-translate/[email protected] --save
npm i @ngx-translate/[email protected] --save
npm i [email protected] --save
npm i @softwarepioniere/language@^0.0.8 --save

Configuration

app.module.ts

imports: [
    ...
    NgrxManagerModule.forRoot(),
    ...

Sample implementation

The following code are available on github.

First you must add the ngrxManager to your actions like...

(anyActions).actions.ts

import {Action} from '@ngrx/store';
import {NgrxManagerConfig} from '@softwarepioniere/ngrx-manager/lib/model';
import {Post} from '../../data-api';

export const RESET_ACTION = '[ActionList] App reset';

export const GET_POSTS_ACTION = '[ActionList] Load posts';
export const GET_POSTS_SUCCESS_ACTION = '[ActionList] Loading posts succeeded';
export const GET_POSTS_FAILED_ACTION = '[ActionList] Loading posts failed';

export const POST_INSERT_POST_ACTION = '[ActionList] Insert Post';
export const POST_INSERT_POST_SUCCESS_ACTION = '[ActionList] Insert Post succeeded';
export const POST_INSERT_POST_FAILED_ACTION = '[ActionList] Insert Post failed';


export class ResetAction implements Action {
    readonly type = RESET_ACTION;

    constructor() {
    }
}

// GET POSTS
export class GetPostsAction implements Action {
    readonly type = GET_POSTS_ACTION;

    constructor(public optPayload: any = null, public ngrxManager: NgrxManagerConfig = null) {
    }
}


export class GetPostsSuccessAction implements Action {
    readonly type = GET_POSTS_SUCCESS_ACTION;

    constructor(public payload: any, public optPayload: any = null, public ngrxManager: NgrxManagerConfig = null) {
    }
}


export class GetPostsFailedAction implements Action {
    readonly type = GET_POSTS_FAILED_ACTION;

    constructor(public payload: any, public optPayload: any = null, public ngrxManager: NgrxManagerConfig = null) {
    }
}

// POST INSERT POST
export class PostInsertPostAction implements Action {
    readonly type = POST_INSERT_POST_ACTION;

    constructor(public post: Post, public optPayload: any = null, public ngrxManager: NgrxManagerConfig = null) {
    }
}


export class PostInsertPostSuccessAction implements Action {
    readonly type = POST_INSERT_POST_SUCCESS_ACTION;

    constructor(public payload: any, public optPayload: any = null, public ngrxManager: NgrxManagerConfig = null) {
    }
}


export class PostInsertPostFailedAction implements Action {
    readonly type = POST_INSERT_POST_FAILED_ACTION;

    constructor(public payload: any, public optPayload: any = null, public ngrxManager: NgrxManagerConfig = null) {
    }
}

export type Actions =
    GetPostsAction
    | GetPostsSuccessAction
    | GetPostsFailedAction
    | PostInsertPostAction
    | PostInsertPostSuccessAction
    | PostInsertPostFailedAction
    | ResetAction
    ;

First you must change your query and post effects, so that each call use the ngrxManager to check if call can execute or must be wait.

(anyQuery).effects.ts

@Effect()
    getPosts$: Observable<Action> = this.actions$.pipe(
        ofType(ac.GET_POSTS_ACTION),
        map((x: ac.GetPostsAction) => {
            return this.ngrxManagerService.checkRequestCall(ac.GET_POSTS_ACTION, x, RequestMethod.QUERY, RequestType.Anfrage);
        }),
        filter(x => typeof x !== 'boolean'),
        flatMap((x: ac.GetPostsAction) => {
            const optPayload = (x !== undefined && x !== null && x.optPayload !== undefined) ? x.optPayload : null;
            return this._dataService.getPosts()
                .map((result: any) => {
                    const nextAction = new ac.GetPostsSuccessAction(result, optPayload);
                    this.ngrxManagerService.checkRequestResult(ac.GET_POSTS_ACTION, x, RequestMethod.QUERY, RequestType.Erfolgreich, nextAction);
                    return nextAction;
                })
                .catch((error: any) => {
                    const nextAction = new ac.GetPostsFailedAction(error, optPayload);
                    this.ngrxManagerService.checkRequestResult(ac.GET_POSTS_ACTION, x, RequestMethod.QUERY, RequestType.Fehler, nextAction, error);
                    return of(nextAction);
                });
        })
    );

(anyPost).effects.ts

 @Effect()
    insertPost$: Observable<Action> = this.actions$.pipe(
        ofType(ac.POST_INSERT_POST_ACTION),
        map((x: ac.GetPostsAction) => {
            return this.ngrxManagerService.checkRequestCall(ac.POST_INSERT_POST_ACTION, x, RequestMethod.COMMAND, RequestType.Anfrage);
        }),
        filter(x => typeof x !== 'boolean'),
        flatMap((x: ac.PostInsertPostAction) => {
            const optPayload = (x !== undefined && x !== null && x.optPayload !== undefined) ? x.optPayload : null;
            return this._dataService.postInsertPost()
                .map((result: any) => {
                    const nextAction = new ac.PostInsertPostSuccessAction(result, optPayload);
                    this.ngrxManagerService.checkRequestResult(ac.POST_INSERT_POST_ACTION, x, RequestMethod.COMMAND, RequestType.Erfolgreich, nextAction);
                    return nextAction;
                })
                .catch((error: any) => {
                    const nextAction = new ac.PostInsertPostFailedAction(error, optPayload);
                    this.ngrxManagerService.checkRequestResult(ac.POST_INSERT_POST_ACTION, x, RequestMethod.COMMAND, RequestType.Fehler, nextAction, error);
                    return of(nextAction);
                });
        })
    );

Application Insight

To track track executed, non executed, failed or succeeded query, the ngrxManager send this actions:

export const INSIGHTS_QUERY_NOT_EXECUTED = '[SopiNgrxManager] Insights :: Query execution';
export const INSIGHTS_QUERY_EXECUTE = '[SopiNgrxManager] Insights :: Query execution';
export const INSIGHTS_QUERY_SUCCESS = '[SopiNgrxManager] Insights :: Query success';
export const INSIGHTS_QUERY_FAILED = '[SopiNgrxManager] Insights :: Query failed';
export const INSIGHTS_QUERY_FAILED_BAD_REQUEST = '[SopiNgrxManager] Insights :: Query failed with bad request';

export const INSIGHTS_COMMAND_NOT_EXECUTED = '[SopiNgrxManager] Insights :: Command execution';
export const INSIGHTS_COMMAND_EXECUTE = '[SopiNgrxManager] Insights :: Command execution';
export const INSIGHTS_COMMAND_SUCCESS = '[SopiNgrxManager] Insights :: Command success';
export const INSIGHTS_COMMAND_FAILED = '[SopiNgrxManager] Insights :: Command failed';
export const INSIGHTS_COMMAND_FAILED_BAD_REQUEST = '[SopiNgrxManager] Insights :: Command failed with bad request';