All Projects → ngrx → Store

ngrx / Store

Licence: mit
RxJS powered state management for Angular applications, inspired by Redux

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Store

Taskmgr
a team collaboration tutorial app like teambition/worktile
Stars: ✭ 95 (-97.6%)
Mutual labels:  rxjs, ngrx
ts-action-operators
TypeScript action operators for NgRx and redux-observable
Stars: ✭ 34 (-99.14%)
Mutual labels:  rxjs, ngrx
Example App
Example app showcasing the ngrx platform
Stars: ✭ 1,361 (-65.62%)
Mutual labels:  rxjs, ngrx
Angular Ngrx Data
Angular with ngRx and experimental ngrx-data helper
Stars: ✭ 954 (-75.9%)
Mutual labels:  rxjs, ngrx
angular2-instagram
🔥Instagram like photo filter playground built with Angular2 (Web | Desktop)
Stars: ✭ 91 (-97.7%)
Mutual labels:  rxjs, ngrx
Ngrx Ducks
Improved Coding Experience for NgRx
Stars: ✭ 56 (-98.59%)
Mutual labels:  rxjs, ngrx
Router Store
Bindings to connect the Angular Router to @ngrx/store
Stars: ✭ 187 (-95.28%)
Mutual labels:  rxjs, ngrx
Soundcloud Ngrx
SoundCloud API client with Angular • RxJS • ngrx/store • ngrx/effects
Stars: ✭ 438 (-88.94%)
Mutual labels:  rxjs, ngrx
kanban-project-management
Web Application to manage software development projects.
Stars: ✭ 39 (-99.01%)
Mutual labels:  rxjs, ngrx
community-events-angular
Community Events App built with ❤️ using Angular, NgRx, Rxjs to do thrill in #hacktoberfest21
Stars: ✭ 20 (-99.49%)
Mutual labels:  rxjs, ngrx
Platform
Reactive libraries for Angular
Stars: ✭ 7,020 (+77.32%)
Mutual labels:  rxjs, ngrx
Keyist-Ecommerce
🔑 A simple ecommerce site powered with Spring Boot + Angular 10 + Ngrx + OAuth2
Stars: ✭ 220 (-94.44%)
Mutual labels:  rxjs, ngrx
Angularfire
The official Angular library for Firebase.
Stars: ✭ 7,029 (+77.54%)
Mutual labels:  rxjs, ngrx
Game Music Player
All your music are belong to us
Stars: ✭ 76 (-98.08%)
Mutual labels:  rxjs, ngrx
Angular Learning Resources
Curated chronological list of learning resources for Angular, from complete beginner to advanced level
Stars: ✭ 615 (-84.47%)
Mutual labels:  rxjs, ngrx
Angular Rpg
RPG game built with Typescript, Angular, ngrx/store and rxjs
Stars: ✭ 120 (-96.97%)
Mutual labels:  rxjs, ngrx
streamkit
My streaming overlay platform for YouTube https://bit.ly/3AvaoFz and Twitch https://bit.ly/37xUPAM
Stars: ✭ 15 (-99.62%)
Mutual labels:  rxjs, ngrx
juliette
Reactive State Management Powered by RxJS
Stars: ✭ 84 (-97.88%)
Mutual labels:  rxjs, ngrx
ngrx-signalr-core
A library to handle realtime SignalR (.NET Core) events using @angular, rxjs and the @ngrx library
Stars: ✭ 18 (-99.55%)
Mutual labels:  rxjs, ngrx
Coderplanets web
the most sexiest community for developers, build with React, Mobx/MST, GraphQL, Styled-Components, Rxjs, Ramda ... and ❤️
Stars: ✭ 314 (-92.07%)
Mutual labels:  rxjs

This repository is for version 2.x of @ngrx/store.

Click here for the latest version (4.x)


@ngrx/store

RxJS powered state management for Angular applications, inspired by Redux

Join the chat at https://gitter.im/ngrx/store CircleCI Status for ngrx/store npm version

@ngrx/store is a controlled state container designed to help write performant, consistent applications on top of Angular. Core tenets:

  • State is a single immutable data structure
  • Actions describe state changes
  • Pure functions called reducers take the previous state and the next action to compute the new state
  • State accessed with the Store, an observable of state and an observer of actions

These core principles enable building components that can use the OnPush change detection strategy giving you intelligent, performant change detection throughout your application.

Installation

Install @ngrx/core and @ngrx/store from npm:

npm install @ngrx/core @ngrx/[email protected] --save

Optional packages:

Examples

  • Official @ngrx/example-app is an officially maintained example application showcasing best practices for @ngrx projects, including @ngrx/store and @ngrx/effects
  • angular-webpack2-starter is a complete Webpack 2 starter with built-in support for @ngrx. Includes Ahead-of-Time (AOT) compilation, hot module reloading (HMR), devtools, and server-side rendering.

Introduction

Setup

Create a reducer function for each data type you have in your application. The combination of these reducers will make up your application state:

// counter.ts
import { ActionReducer, Action } from '@ngrx/store';

export const INCREMENT = 'INCREMENT';
export const DECREMENT = 'DECREMENT';
export const RESET = 'RESET';

export function counterReducer(state: number = 0, action: Action) {
	switch (action.type) {
		case INCREMENT:
			return state + 1;

		case DECREMENT:
			return state - 1;

		case RESET:
			return 0;

		default:
			return state;
	}
}

In your app's main module, import those reducers and use the StoreModule.provideStore(reducers) function to provide them to Angular's injector:

import { NgModule } from '@angular/core'
import { StoreModule } from '@ngrx/store';
import { counterReducer } from './counter';

@NgModule({
  imports: [
    BrowserModule,
    StoreModule.provideStore({ counter: counterReducer })
  ]
})
export class AppModule {}

You can then inject the Store service into your components and services. Use store.select to select slice(s) of state:

import { Store } from '@ngrx/store';
import { INCREMENT, DECREMENT, RESET } from './counter';

interface AppState {
  counter: number;
}

@Component({
	selector: 'my-app',
	template: `
		<button (click)="increment()">Increment</button>
		<div>Current Count: {{ counter | async }}</div>
		<button (click)="decrement()">Decrement</button>

		<button (click)="reset()">Reset Counter</button>
	`
})
class MyAppComponent {
	counter: Observable<number>;

	constructor(private store: Store<AppState>){
		this.counter = store.select('counter');
	}

	increment(){
		this.store.dispatch({ type: INCREMENT });
	}

	decrement(){
		this.store.dispatch({ type: DECREMENT });
	}

	reset(){
		this.store.dispatch({ type: RESET });
	}
}

Contributing

Please read contributing guidelines here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].