@clarium/ngce-services v0.0.1-beta
Here is a similar README file structure for ngce-services:
ngce-services
ngce-services is a comprehensive collection of Angular services that simplify common development tasks, such as HTTP requests, authentication, data caching, and more. Designed for efficiency and scalability, ngce-services helps developers integrate powerful functionalities into their Angular applications with ease.
Table of Contents
Features
- Ready-to-use Angular services for common tasks like HTTP requests, authentication, and caching.
- Lightweight and optimized for performance.
- Compatible with Angular versions 8.0.0 to 18.2.0.
- Follows Angular best practices and patterns for dependency injection.
- Easily customizable to fit your application’s needs.
- Supports both standalone and multi-module Angular applications.
Installation
To install ngce-services, you can use npm. If the package is private, ensure you are logged in to your npm account with the correct permissions.
Public Installation (if the package is public):
npm install @clarium/ngce-services --save
Private Installation (if the package is private):
Make sure you have access to your organization’s private npm packages:
npm install @clarium/ngce-services --save
Also, install the necessary peer dependencies if they are not already included in your project:
npm install @angular/common @angular/core rxjs tslib --save
Getting Started
Once the package is installed, you can start using the services in your Angular application by importing the StorageService
into your root module (app.module.ts
) or directly in your components:
import { StorageService } from '@clarium/ngce-services';
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule
],
providers: [StorageService],
bootstrap: [AppComponent]
})
export class AppModule {}
Usage
Basic Example
Here’s how to use the ngce-storage-service :
In your component:
import { StorageService } from '@clarium/ngce-services';
export class AppComponent {
constructor(private _storage: StorageService) {}
setData(input: string) {
this._storage.setItem('test', input)
}
getData() {
return this._storage.getItem('test')
}
}
In your template:
<button (click)="getData()">Fetch Data</button>
Configuring Services
You can easily configure the behavior of services :
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { NgceComponentsModule, SnackbarService } from '@clarium/ngce-components';
import { StorageService } from '@clarium/ngce-services';
@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet, NgceComponentsModule],
providers: [SnackbarService, StorageService],
templateUrl: './app.component.html',
styleUrl: './app.component.css'
})
export class AppComponent {
title = 'test-app';
constructor(private _snackbar: SnackbarService, private _storage: StorageService) {}
submit() {
this._storage.setItem('test','Hello from snackbar')
this._snackbar.show(this._storage.getItem('test') || 'hello');
}
}
Documentation
For detailed documentation and configuration options for each service, refer to the official documentation.
Included services:
api-service
: A service for making HTTP requests.http-error-handler
: Handling errors on making HTTP Requests.http-utility
: A service for constructing URLs.storage-service
: Simplified access to local and session storage.- And many more...
Visit the documentation for the full list and examples.
License
This library is licensed under the MIT License. See the LICENSE file for more information.
10 months ago