18.0.10 • Published 12 months ago

@ea-controls/ngrx-repository-webapi v18.0.10

Weekly downloads
-
License
-
Repository
-
Last release
12 months ago

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.

OptionDescriptionInputOutput
urlBaseBase URL for all API requests--
transformResponseTransform data before updating the ngrx modeldata returned by httpClient.get methodProcessed data by user
tranformBeforeSendingDataModify data before making httpClient.post/patch/delete requestdata sent in ngrx actionProcessed data by user
getUrlURL used in httpClient.get methodCurrent EntityAdapterURL string (default ${urlBase}/${adapterName})
postUrlURL used in httpClient.post methodCurrent EntityAdapter and dataURL string (default ${urlBase}/${adapterName})
patchUrlURL used in httpClient.patch methodCurrent EntityAdapter and dataURL string (default ${urlBase}/${adapterName}/${id})
removeUrlURL used in httpClient.delete methodCurrent EntityAdapter and dataURL string (default ${urlBase}/${adapterName}/${id})
updateWithPatchIf update should be patch or put verbtrue/false-
18.0.10

12 months ago

18.0.9

12 months ago

18.0.8

12 months ago

18.0.7

12 months ago

18.0.6

12 months ago

18.0.5

12 months ago

18.0.4

12 months ago

18.0.3

12 months ago

18.0.2

12 months ago

18.0.1

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago