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-interceptor

v1.0.0

Published

Angular/Ionic ready to use http interceptor which show a default spinner while the app is waiting the http response. Highly configurable with several settings and customizable message or spinner

Downloads

15

Readme

NgxInterceptor

npm version GitHub issues GitHub license

Demo

Basic version demo

Install

npm i ngx-interceptor

Usage

Add ngx-interceptor to your root app file.

//app.modaule.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { NgxInterceptorModule } from 'ngx-interceptor';

@NgModule({
  declarations: [ AppComponent ],
  imports: [
    BrowserModule,
    NgxInterceptorModule.forRoot()
  ],
  bootstrap: [ AppComponent ]
})

export class AppModule { }
<!-- app.component.html -->
<ngx-interceptor></ngx-interceptor>

Settings

Endpoints filter

The default behavior of the interceptor is to "catch" every http request. However, the component accepts two kind of inputs to filter these endpoints (exceptions or strict) and will filter every request which contain some of the given text. The input endpoints format could be as an array or an object:

const endPoints: string[] = [ 'users/id', 'users/create', 'location/nearby'];

or

const endPoints: {[key: string]: string} = {
  users: ['id', 'create'],
  location: ['nearby']
 }

The two different endpoints filters are:

  • Exceptions: every endpoint will be intercepted except the given ones
<ngx-interceptor [exceptions]="endPoints"></ngx-interceptor>
  • Strict: only the given endpoints will be intercepted
<ngx-interceptor [strict]="endPoints"></ngx-interceptor>

Lag

The default behavior of the interceptor is to only show the interceptor when there is a lag of 300ms between the request and the response in order to avoid blinking effects. This lag can be modified with the following input:

<ngx-interceptor lag="500"></ngx-interceptor>

In this example the time lag has been changed to 500ms.

Color

The interceptor has a default blue (#0051ff) spinner to show when it is waiting a response. The spinner color can be changed easily by the following input (accept any kind of CSS color):

<ngx-interceptor color="green"></ngx-interceptor>

or

<ngx-interceptor color="#008000"></ngx-interceptor>

or

<ngx-interceptor color="rgb(0,128,0)"></ngx-interceptor>

Custom spinner/modal

Default spinner can be easily replace with a custom spinner or modal wrapping the content inside the ngx-interceptor tag:

<ngx-interceptor>
    //... Add here the custom html content
</ngx-interceptor>