Getting Started
Angular
Install these libraries:
sh
npm i -s @state-adapt/core
npm i -s @state-adapt/rxjs
npm i -s @state-adapt/angularOnce installed, StateAdapt is ready to use. Examples
For configuration options, see @state-adapt/angular.
With NgRx/Store
You probably don't need this.
This enables
- Redux Devtools to sync and show both stores' states together
- Selecting from both global states. StateAdapt's state is nested in a hidden top-level
adaptreducer.
DEPRECATED
The @state-adapt/ngrx library is deprecated and will be removed in StateAdapt v4.
If you still need it, copy the files from https://github.com/state-adapt/state-adapt/tree/main/libs/ngrx/src/lib into your project and use them directly.
First, install:
sh
npm i -s @state-adapt/{core,rxjs,angular,ngrx}Add to the root NgRx/Store config:
ts
import { isDevMode } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { provideStore } from '@ngrx/store';
import { provideStoreDevtools } from '@ngrx/store-devtools';
import { adaptReducer, actionSanitizer, stateSanitizer } from '@state-adapt/core';
import { AppComponent } from './app.component';
bootstrapApplication(AppComponent, {
providers: [
provideStore({
count: counterReducer,
adapt: adaptReducer,
}),
provideStoreDevtools({
logOnly: !isDevMode(),
actionSanitizer,
stateSanitizer,
}),
],
});Now in a component or service:
typescript
import { adaptNgrx } from '@state-adapt/ngrx';
// ...
nameStore = adaptNgrx('Bob');