Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# NgRx Toolkit

[![npm](https://img.shields.io/npm/v/%40angular-architects%2Fngrx-toolkit.svg)](https://www.npmjs.com/package/%40angular-architects%2Fngrx-toolkit)
[![npm](https://img.shields.io/npm/v/%40ngrx-toolkit%2Fcore.svg)](https://www.npmjs.com/package/%40ngrx-toolkit%2Fcore)

<a href="https://angular-architects.github.io/ngrx-toolkit/"><img src="https://raw.githubusercontent.com/angular-architects/ngrx-toolkit/main/logo.png" width="320" style="text-align: center" /></a>
<a href="https://ngrx-toolkit.github.io/ngrx-toolkit/"><img src="https://raw.githubusercontent.com/ngrx-toolkit/ngrx-toolkit/main/logo.png" width="320" style="text-align: center" /></a>

NgRx Toolkit is a set of extensions to the NgRx Signals Store, like

Expand All @@ -11,10 +11,12 @@ NgRx Toolkit is a set of extensions to the NgRx Signals Store, like
- Storage Sync: Synchronize the Store with Web Storage
- [Redux Connector: Map NgRx Store Actions to a present Signal Store](libs/ngrx-toolkit/redux-connector/docs/README.md)

> Starting with v22, the package is published as `@ngrx-toolkit/core`. For v21 and earlier, use `@angular-architects/ngrx-toolkit`.

To install it, run

```shell
npm i @angular-architects/ngrx-toolkit
npm i @ngrx-toolkit/core
```

For a more detailed guide on installation, setup, and usage, head to the [**Documentation**](https://ngrx-toolkit.angulararchitects.io/).
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/app/category.store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { withDevtools } from '@angular-architects/ngrx-toolkit';
import { withDevtools } from '@ngrx-toolkit/core';
import { patchState, signalStore, withHooks } from '@ngrx/signals';
import { setAllEntities, withEntities } from '@ngrx/signals/entities';

Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/app/counter-mutation/counter.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
httpMutation,
rxMutation,
withMutations,
} from '@angular-architects/ngrx-toolkit';
} from '@ngrx-toolkit/core';
import { patchState, signalStore, withState } from '@ngrx/signals';
import { delay, Observable } from 'rxjs';

Expand Down
6 changes: 1 addition & 5 deletions apps/demo/src/app/counter-rx-mutation/counter-rx-mutation.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import {
concatOp,
httpMutation,
rxMutation,
} from '@angular-architects/ngrx-toolkit';
import { CommonModule } from '@angular/common';
import { Component, computed, signal } from '@angular/core';
import { concatOp, httpMutation, rxMutation } from '@ngrx-toolkit/core';
import { delay, Observable, of, throwError } from 'rxjs';

export type Params = {
Expand Down
6 changes: 3 additions & 3 deletions apps/demo/src/app/devtools/todo-detail.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Component, effect, inject, input } from '@angular/core';
import { MatCardModule } from '@angular/material/card';
import {
renameDevtoolsName,
withDevtools,
withGlitchTracking,
withMapper,
} from '@angular-architects/ngrx-toolkit';
import { Component, effect, inject, input } from '@angular/core';
import { MatCardModule } from '@angular/material/card';
} from '@ngrx-toolkit/core';
import { patchState, signalStore, withHooks, withState } from '@ngrx/signals';
import { Todo } from '../shared/todo.service';

Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/app/devtools/todo-store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { updateState, withDevtools } from '@angular-architects/ngrx-toolkit';
import { computed, inject } from '@angular/core';
import { updateState, withDevtools } from '@ngrx-toolkit/core';
import {
signalStore,
withComputed,
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/app/events-sample/book.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
withDevtools,
withGlitchTracking,
withTrackedReducer,
} from '@angular-architects/ngrx-toolkit';
} from '@ngrx-toolkit/core';
import { signalStore, withComputed, withHooks, withState } from '@ngrx/signals';
import { injectDispatch, on } from '@ngrx/signals/events';
import { bookEvents } from './book-events';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { withFeatureFactory } from '@angular-architects/ngrx-toolkit';
import { Component, inject } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MatButton } from '@angular/material/button';
import { withFeatureFactory } from '@ngrx-toolkit/core';
import {
patchState,
signalStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
withCallState,
withDataService,
withUndoRedo,
} from '@angular-architects/ngrx-toolkit';
} from '@ngrx-toolkit/core';
import { withEntities } from '@ngrx/signals/entities';
import { Flight } from '../shared/flight';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
withCallState,
withDataService,
withUndoRedo,
} from '@angular-architects/ngrx-toolkit';
} from '@ngrx-toolkit/core';
import { withEntities } from '@ngrx/signals/entities';
import { Flight } from '../shared/flight';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
createReduxState,
mapAction,
withActionMappers,
} from '@angular-architects/ngrx-toolkit/redux-connector';
} from '@ngrx-toolkit/core/redux-connector';
import { ticketActions } from './actions';
import { FlightStore } from './store';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { reduxMethod } from '@angular-architects/ngrx-toolkit/redux-connector';
import { computed, inject } from '@angular/core';
import { reduxMethod } from '@ngrx-toolkit/core/redux-connector';
import {
patchState,
signalStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
withCallState,
withDataService,
withPagination,
} from '@angular-architects/ngrx-toolkit';
} from '@ngrx-toolkit/core';
import { patchState, signalStore, type, withMethods } from '@ngrx/signals';
import { withEntities } from '@ngrx/signals/entities';
import { Flight } from '../shared/flight';
Expand Down
6 changes: 3 additions & 3 deletions apps/demo/src/app/flight-search/flight-store.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { HttpClient, HttpParams } from '@angular/common/http';
import { inject } from '@angular/core';
import {
noPayload,
payload,
updateState,
withDevtools,
withRedux,
} from '@angular-architects/ngrx-toolkit';
import { HttpClient, HttpParams } from '@angular/common/http';
import { inject } from '@angular/core';
} from '@ngrx-toolkit/core';
import { signalStore, withState } from '@ngrx/signals';
import { map, switchMap } from 'rxjs';
import { Flight } from './flight';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { withImmutableState } from '@angular-architects/ngrx-toolkit';
import { Component, inject } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MatButton } from '@angular/material/button';
import { withImmutableState } from '@ngrx-toolkit/core';
import { patchState, signalStore, withMethods } from '@ngrx/signals';

const initialState = { user: { id: 1, name: 'Konrad' } };
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/app/reset/todo-store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setResetState, withReset } from '@angular-architects/ngrx-toolkit';
import { setResetState, withReset } from '@ngrx-toolkit/core';
import {
getState,
patchState,
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/app/shared/flight.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DataService } from '@angular-architects/ngrx-toolkit';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { DataService } from '@ngrx-toolkit/core';
import { EntityId } from '@ngrx/signals/entities';
import { firstValueFrom, Observable } from 'rxjs';
import { Flight } from './flight';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { inject, resource } from '@angular/core';
import {
httpMutation,
withEntityResources,
withMutations,
} from '@angular-architects/ngrx-toolkit';
import { inject, resource } from '@angular/core';
} from '@ngrx-toolkit/core';
import { patchState, signalStore, withMethods, withState } from '@ngrx/signals';
import { addEntity, removeEntity, updateEntity } from '@ngrx/signals/entities';
import { firstValueFrom } from 'rxjs';
Expand Down
5 changes: 1 addition & 4 deletions apps/demo/src/app/todo-indexeddb-sync/synced-todo-store.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {
withIndexedDB,
withStorageSync,
} from '@angular-architects/ngrx-toolkit';
import { inject } from '@angular/core';
import { withIndexedDB, withStorageSync } from '@ngrx-toolkit/core';
import { getState, patchState, signalStore, withMethods } from '@ngrx/signals';
import {
removeEntity,
Expand Down
5 changes: 1 addition & 4 deletions apps/demo/src/app/todo-storage-sync/synced-todo-store.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {
withLocalStorage,
withStorageSync,
} from '@angular-architects/ngrx-toolkit';
import { inject } from '@angular/core';
import { withLocalStorage, withStorageSync } from '@ngrx-toolkit/core';
import { getState, patchState, signalStore, withMethods } from '@ngrx/signals';
import {
removeEntity,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { withConditional } from '@angular-architects/ngrx-toolkit';
import { Component, effect, inject, signal, untracked } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MatButton } from '@angular/material/button';
import {
MatButtonToggle,
MatButtonToggleGroup,
} from '@angular/material/button-toggle';
import { withConditional } from '@ngrx-toolkit/core';
import {
patchState,
signalStore,
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/app/with-resource/with-resource.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { withResource } from '@angular-architects/ngrx-toolkit';
import { JsonPipe } from '@angular/common';
import { httpResource } from '@angular/common/http';
import { Component, inject } from '@angular/core';
import { withResource } from '@ngrx-toolkit/core';
import { signalStore, withState } from '@ngrx/signals';
import { Flight } from '../shared/flight';

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/create-redux-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ title: createReduxState()
---

```typescript
import { createReduxState } from '@angular-architects/ngrx-toolkit/redux-connector';
import { createReduxState } from '@ngrx-toolkit/core/redux-connector';
```

The Redux Connector it is not an extension but turns any `signalStore()` into a Global State Management Slice following the Redux pattern.

It is available as secondary entry point, i.e. `import { createReduxState } from '@angular-architects/ngrx-toolkit/redux-connector'` and has a dependency to `@ngrx/store`.
It is available as secondary entry point, i.e. `import { createReduxState } from '@ngrx-toolkit/core/redux-connector'` and has a dependency to `@ngrx/store`.

An extension without dependency to `@ngrx/store` is available with [`withRedux()`](./with-redux).

Expand Down
8 changes: 7 additions & 1 deletion docs/docs/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ title: Extensions

The NgRx Toolkit is a set of extensions to the NgRx SignalsStore.

:::note Package name for v22

Starting with v22, install and import the toolkit as `@ngrx-toolkit/core`. For v21 and earlier, use `@angular-architects/ngrx-toolkit`.

:::

It offers extensions like:

- [⭐️ Devtools](./with-devtools): Integration into Redux Devtools
Expand All @@ -22,5 +28,5 @@ It offers extensions like:
To install it, run

```shell
npm i @angular-architects/ngrx-toolkit
npm i @ngrx-toolkit/core
```
16 changes: 8 additions & 8 deletions docs/docs/mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ title: Mutations
---

```typescript
import { httpMutation } from '@angular-architects/ngrx-toolkit';
import { httpMutation } from '@ngrx-toolkit/core';
```

```typescript
import { rxMutation } from '@angular-architects/ngrx-toolkit';
import { rxMutation } from '@ngrx-toolkit/core';
```

```typescript
import { withMutations } from '@angular-architects/ngrx-toolkit';
import { withMutations } from '@ngrx-toolkit/core';
```

```typescript
// Optional, `concatOp` is the default.
import { concatOp, exhaustOp, mergeOp, switchOp } from '@angular-architects/ngrx-toolkit';
import { concatOp, exhaustOp, mergeOp, switchOp } from '@ngrx-toolkit/core';
```

## Basic Usage
Expand All @@ -34,7 +34,7 @@ This guide covers
- State signals available (`value/status/error/isPending`)
<!-- TODO - resolve when #235 closed-->
- For `httpMutation`, the response type is specified with the param `parse: (res: T) => res as T`
- `hasValue` signal to narrow type. ⚠️NOTE⚠️: currently there is an [outstanding bug](https://github.com/angular-architects/ngrx-toolkit/issues/235) that this does not properly narrow.
- `hasValue` signal to narrow type. ⚠️NOTE⚠️: currently there is an [outstanding bug](https://github.com/ngrx-toolkit/ngrx-toolkit/issues/235) that this does not properly narrow.
- [How to use](#usage-withmutations-or-solo-functions), as:
- _standalone functions_
- In `withMutations` store _feature_
Expand Down Expand Up @@ -185,7 +185,7 @@ Enables handling race conditions
increment: rxMutation({
// ...
// Passing in a custom option. Need to import like:
// import { switchOp } from '@angular-architects/ngrx-toolkit'
// import { switchOp } from '@ngrx-toolkit/core'
operator: mergeOp, // `concatOp` is the default if `operator` is omitted
}),

Expand Down Expand Up @@ -337,7 +337,7 @@ class CounterMutation {
increment: rxMutation({
// ...
// Passing in a custom option. Need to import like:
// import { switchOp } from '@angular-architects/ngrx-toolkit'
// import { switchOp } from '@ngrx-toolkit/core'
operator: mergeOp, // `concatOp` is the default if `operator` is omitted
}),
})),
Expand Down Expand Up @@ -410,7 +410,7 @@ This example is a dedicated store with `withMutations` and used in a component,
### Declare

```ts
import { concatOp, httpMutation, rxMutation, withMutations } from '@angular-architects/ngrx-toolkit';
import { concatOp, httpMutation, rxMutation, withMutations } from '@ngrx-toolkit/core';
import { patchState, signalStore, withState } from '@ngrx/signals';
import { delay, Observable } from 'rxjs';

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/team.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ import Team from '@site/src/components/Team';

## Contribute

We welcome contributions from the community! If you're interested in contributing to NgRx Toolkit, check out our [GitHub repository](https://github.com/angular-architects/ngrx-toolkit) and our [contribution guidelines](https://github.com/angular-architects/ngrx-toolkit/blob/main/CONTRIBUTING.md).
We welcome contributions from the community! If you're interested in contributing to NgRx Toolkit, check out our [GitHub repository](https://github.com/ngrx-toolkit/ngrx-toolkit) and our [contribution guidelines](https://github.com/ngrx-toolkit/ngrx-toolkit/blob/main/CONTRIBUTING.md).
4 changes: 2 additions & 2 deletions docs/docs/with-call-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: withCallState()
---

```typescript
import { withCallState } from '@angular-architects/ngrx-toolkit';
import { withCallState } from '@ngrx-toolkit/core';
```

`withCallState` adds call state management capabilities to NgRx signal stores, tracking the status of asynchronous operations with built-in states for loading, loaded, and error conditions.
Expand Down Expand Up @@ -43,7 +43,7 @@ The call state can be one of these types:
## Usage

```typescript
import { withCallState, setLoading, setLoaded, setError } from '@angular-architects/ngrx-toolkit';
import { withCallState, setLoading, setLoaded, setError } from '@ngrx-toolkit/core';

const store = signalStore(
withCallState(),
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/with-conditional.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: withConditional()
---

```typescript
import { withConditional } from '@angular-architects/ngrx-toolkit';
import { withConditional } from '@ngrx-toolkit/core';
```

`withConditional` activates a feature based on a given condition.
Expand All @@ -21,7 +21,7 @@ Otherwise, a type error will occur.
## Usage

```typescript
import { withConditional } from '@angular-architects/ngrx-toolkit';
import { withConditional } from '@ngrx-toolkit/core';

const withUser = signalStoreFeature(
withState({ id: 1, name: 'Konrad' }),
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/with-data-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ title: withDataService()
---

```typescript
import { withDataService } from '@angular-architects/ngrx-toolkit';
import { withDataService } from '@ngrx-toolkit/core';
```

`withDataService()` allows to connect a Data Service to the store:

This gives you a store for a CRUD use case:

```typescript
import { withDataService, withCallState, withUndoRedo } from '@angular-architects/ngrx-toolkit';
import { withDataService, withCallState, withUndoRedo } from '@ngrx-toolkit/core';

export const SimpleFlightBookingStore = signalStore(
{ providedIn: 'root' },
Expand Down Expand Up @@ -92,7 +92,7 @@ export class FlightSearchSimpleComponent {
To avoid naming conflicts, the properties set up by `withDataService` and the connected features can be configured in a typesafe way:

```typescript
import { withDataService, withCallState, withUndoRedo } from '@angular-architects/ngrx-toolkit';
import { withDataService, withCallState, withUndoRedo } from '@ngrx-toolkit/core';

export const FlightBookingStore = signalStore(
{ providedIn: 'root' },
Expand Down
Loading
Loading