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

ng.http.lib

v0.0.2

Published

A Reactive __HTTP__ module for Angular. Reactive? Yes, I super-charged the module with the [RxJS library](https://github.com/ReactiveX/rxjs).

Downloads

2

Readme

ng.http

A Reactive HTTP module for Angular. Reactive? Yes, I super-charged the module with the RxJS library.

RxJS is a library that brings Reactivity (notion of data/events over time) to JavaScript.

RxJS stands for __R__eactive E__x__tensions for __J__ava__S__cript.

This is my own implementation/clone of the Angular HTTP module.

Installation

You can pull in from NPM using the command:

npm i ng.http.lib -S

Using yarn:

yarn add ng.http.lib

Yeah, I know, the name looks weird and with the double dots, its kind of creepy, I would say. I originally named it ng_http, but I couldn't publish with the name 'cos of too many similiar names on NPM, so I had to conjure up that.

Usage

Import the HttpModule in app.module.ts file:

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

import { AppComponent } from './app.component';
import { HttpModule } from 'ng.http.lib'

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    HttpModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Http class was implemented. Like in the official Angular HTTP module, it has methods for CRUDy requests:

  • get
  • post
  • delete
  • put
  • patch

Though, I only implemented the get method. Don't worry, I'll fix other methods or you can help by contributing to the project. I built this module just to demonstrate how Angular modules work and how RxJS (Reactive Programming) was incorporated into the HTTP module unlike other Promise-based HTTP libraries we have always seen (axios etc.).

The Http class is available to the whole Angular app because it was added to HttpModule's providers array. So you do not have to re-import it in your own sub-modules. So, inorder to use HTTP methods, import it in your Component/Directive/Service like this:

import { Component, OnInit } from '@angular/core';
import { Http } from 'ng.http.lib'

@Component({
  selector: 'app-todo',
  template: `
    <p>
      todo works!
    </p>
    <button (click)="see()">See</button>
  `,
  styles: []
})
export class TodoComponent implements OnInit {

  constructor(private http: Http) { }

  see() {
    this.http.get('http://localhost:3000/api')
      .subscribe((v) => alert(v),err=>alert(`Error`))
  }
}

You see the this.http.get method returns an Observable, which we subscribe to the stream, to get our values.

Authors