Skip to content

alobuuls/angular-localstorage-service

Repository files navigation

πŸ—„οΈ Angular LocalStorage Service

Angular TypeScript LocalStorage Service Completed

Repository GitHub Stars Last Commit


πŸ“‘ Table of Contents


🌐 Live Demo

πŸ”— https://alobuuls.github.io/angular-localstorage-service/


πŸ“– Description

Note

An Angular 16 application that implements a reusable LocalStorage service with configurable key prefixes and custom pipes.

The project demonstrates how to encapsulate browser storage operations behind reusable Angular services and modules, avoiding direct access to the Local Storage API while improving maintainability, scalability, and code organization.


βš™οΈ System Requirements

Before running the project, make sure you have installed:

  • πŸ“¦ Node.js: v16.14.x – v18.x (recommended: v18 LTS)
  • πŸ“¦ npm: v8+
  • πŸ…°οΈ Angular CLI: v16.x

Recommended using nvm

nvm install 18
nvm use 18

πŸ” Verify Installed Versions

Run the following commands in your terminal:

node -v
npm -v
ng version

πŸš€ Project Installation

1️⃣ Clone the repository

git clone git@github.com:alobuuls/angular-localstorage-service.git

cd angular-localstorage-service

2️⃣ Install dependencies

npm install

▢️ Run the Project

Start the development server:

ng serve

Then open:

http://localhost:4200

🧠 Project Architecture

The application follows a reusable architecture based on Angular services, modules, and custom pipes.

πŸ—„οΈ LocalStorage Service

Responsible for:

  • Saving values into Local Storage
  • Retrieving stored values
  • Removing stored values
  • Managing configurable prefixes
  • Preventing key collisions

πŸ”„ LocalStorage Pipe

Responsible for:

  • Reading Local Storage values from templates
  • Simplifying UI integration
  • Improving template readability

Example:

{{ 'userName' | localstorage }}

πŸ“¦ LocalStorage Module

Responsible for:

  • Centralizing storage configuration
  • Registering providers
  • Initializing storage settings

🏠 App Component

Responsible for:

  • Demonstrating storage operations
  • Consuming the storage service
  • Testing persistence functionality

✨ Features

  • πŸ’Ύ Store data in Local Storage
  • πŸ” Retrieve values through a custom pipe
  • 🧹 Clear storage by prefix
  • βš™οΈ Configurable key prefixes
  • πŸ“¦ Reusable LocalStorage Service
  • πŸ”„ Custom Angular Pipe
  • πŸš€ APP_INITIALIZER Configuration
  • ♻️ Encapsulated Browser Storage Access

πŸ›  Technologies Used

Technology Purpose
Angular 16 Front-End Framework
TypeScript Application Logic
Local Storage API Browser Persistence
Angular Services Business Logic
Angular Pipes Template Data Access
Angular Modules Feature Organization
APP_INITIALIZER Application Bootstrap Configuration

πŸ“ Project Structure

angular-localstorage-service/

β”œβ”€β”€ src/
β”‚
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ localstorage/
β”‚   β”‚   └── localstorage.module.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ localstorage.service.ts
β”‚   β”œβ”€β”€ localstorage.pipe.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ app.component.ts
β”‚   β”œβ”€β”€ app.component.html
β”‚   β”œβ”€β”€ app.component.css
β”‚   └── app.module.ts
β”‚
β”œβ”€β”€ main.ts
β”œβ”€β”€ styles.css
β”œβ”€β”€ index.html
β”‚
β”œβ”€β”€ angular.json
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── README.md

πŸ”₯ Best Practices Implemented

  • Service-based Architecture
  • Separation of Concerns
  • Encapsulation of Browser APIs
  • Dependency Injection
  • APP_INITIALIZER Configuration
  • Reusable Angular Modules
  • Custom Pipes
  • Strong Typing with TypeScript
  • Centralized Storage Management
  • Clean Project Organization
  • Scalable Front-End Design

🎯 Project Goal

Practice and strengthen Angular architecture concepts through the implementation of a reusable LocalStorage abstraction layer.

Key concepts covered:

  • Angular Services
  • Angular Pipes
  • Angular Modules
  • APP_INITIALIZER
  • Local Storage API
  • Dependency Injection
  • Browser Data Persistence
  • Reusable Architecture Patterns
  • TypeScript Best Practices
  • Front-End Application Design

πŸ“„ License

This project is intended for educational and portfolio purposes.

Created by Alondra Francisco.

About

Angular app demonstrating a reusable LocalStorage service with custom pipe support and configurable prefixes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors