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

@ea-controls/ngrx-repository-webapi

v18.0.10

Published

Extend `@ea-controls/ngrx-repository` to make API calls using the same adapter action calls.

Downloads

31

Readme

repository-webapi

Extend @ea-controls/ngrx-repository to make API calls using the same adapter action calls.

ngrx official documentation

@ea-controls/ngrx-repository

Installation

npm i @ea-controls/ngrx-repository-webapi@latest

Configuration

Follow the same configuration steps as @ea-controls/ngrx-repository. Afterward, configure the web API effects:

Register in app.config.ts (standalone components) the following code


import { EntityAdapter } from "@ea-controls/ngrx-repository";
import { provideRepositoryWebApi } from "@ea-controls/ngrx-repository-webapi";

export const userAdapter = new EntityAdapter<UserEntity>("items");

export const appConfig: ApplicationConfig = {
  providers: [
    ...
    provideRepositoryWebApi({
      adapters: [userAdapter], // <-- Add your adapters
      urlBase: `http://localhost:3000` // <-- Api url base
      ... // <-- Other options
    })
  ],
};

Usage

Follow the same usage instructions as @ea-controls/ngrx-repository.

Note: For fetching data for the first time, you should call the getAll() method manually.

@Component({...})
export class RepositoryComponentWrap implements OnInit {
    
    constructor(private store: Store) { }

    ngOnInit(): void {
        this.store.dispatch(userAdapter.getAll());
    }
}

provideRepositoryWebApi Options

Configure @ea-controls/ngrx-repository-webapi for flexible data transformation and URL formats.

| Option | Description | Input | Output | |-------------------------|------------------------------------------------------|-----------------------------------------|--------------------------------| | urlBase | Base URL for all API requests | - | - | | transformResponse | Transform data before updating the ngrx model | data returned by httpClient.get method | Processed data by user | | tranformBeforeSendingData | Modify data before making httpClient.[post/patch/delete] request | data sent in ngrx action | Processed data by user | | getUrl | URL used in httpClient.get method | Current EntityAdapter | URL string (default ${urlBase}/${adapterName}) | | postUrl | URL used in httpClient.post method | Current EntityAdapter and data | URL string (default ${urlBase}/${adapterName}) | | patchUrl | URL used in httpClient.patch method | Current EntityAdapter and data | URL string (default ${urlBase}/${adapterName}/${id}) | | removeUrl | URL used in httpClient.delete method | Current EntityAdapter and data | URL string (default ${urlBase}/${adapterName}/${id}) | | updateWithPatch | If update should be patch or put verb | true/false | - |