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

response-state

v1.1.0

Published

`response-state` is a HTTP response state indicator handling the life-cycle of the service call from loading, successfull to catched error or if it has been initiated. `response-state` was created in mind of handling day-to-day operations of http-services

Readme

npm Response State

response-state is a HTTP response state indicator handling the life-cycle of the service call from loading, successfull to catched error or if it has been initiated. response-state was created in mind of handling day-to-day operations of http-services for any Angular RxJS project.

Usage

Getting started

npm install response-state

Usage

Service

Begin by extending it to service. Inside the http-request, handle the state as following:

import { HttpClient } from '@angular/common/http';
import { ResponseStateService } from 'response-state';

@Injectable({
  providedIn: 'root'
})
export class YourService extends ResponseStateService {

  constructor(private http: HttpClient) {
    super();
  }

  fetch() {
    // set responseState$ to loading
    this.setLoading();
    return this.http.get(/*insert url*/)
        .pipe(
            map(() => {
                // set responseState$ to successful
                this.setSuccess();
            }),
            catchError(() => {
                // set responseState$ to Error
                this.setError();
            }),
        );
  }

}

Component (*.component.ts)

Initiate the request from your component and observe on the response state observable as below.

import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ResponseState } from 'response-state';
import { Observable } from 'rxjs';
import { YourService } from './your.service';

@Component({
  ...
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AppComponent {
  constructor(private readonly service: YourService) { }

  public readonly state$: Observable<ResponseState> = this.service.responseState$;
  public readonly responseStateTypes: typeof ResponseState = this.service.responseStateTypes;

  // Initiater of your fetch function (use however you would like)
  fetch(): void {
    this.service.fetchData();
  }

Template (*.component.html)

Observe on the state asynchronously and handle loading, success and error cases as needed.

<main *ngIf="(state$ | async) as state">
  <your-loading-component *ngIf="state === responseStateTypes.loading"></your-loading-component>
  <your-success-component *ngIf="state === responseStateTypes.success"></your-success-component>
  <your-error-component *ngIf="state === responseStateTypes.error"></your-error-component>
</main>

API

Operators

| Property | Description | | ----- | ----- | | setLoading | Sets the responseStateType$ to loading | | setError | Sets the responseStateType$ to error | | setSuccess | Sets the responseStateType$ to success |

Subscriptions

| Property | Type | Description | | ----- | ----- | ----- | | isLoading$ | Observable<boolean> | Promise that returns if responseState is set to loading | | isError$ | Observable<boolean> | Promise that returns if responseState is set to error | | isSuccess$ | Observable<boolean> | Promise that returns if responseState is set to success | | responseState$ | Observable<ResponseState> | Promise that returns ResponseState |

Other

| Property | Type | Description | | ----- | ----- | ----- | | responseStateTypes() | typeof ResponseState | Returns type of's ResponseState |

ResponseState (enum)

| Key | Description | | ----- | ----- | | None | When the service has not initiated. May be used to reset the state of the response. | | Loading | Used to check/set state to loading | | Success | Used to check/set state to success | | Error | Used to check/set state to error |

Support

The following table provides the status for response-state versions under support. As a general rule, the latest version of Angular will be maintained for response-state and supported. We strive to keep up-to-date with latest version as soon as available.

| Package version | Angular version | Status | | --------------- | --------------- | ------- | | ^1.0.0 | ^13.0.0 | Active |