@ngdux/list 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +110 -11
  2. package/package.json +13 -3
package/README.md CHANGED
@@ -1,12 +1,19 @@
1
1
  # @ngdux/list
2
2
 
3
- The @ngdux/list gives yo a full state to make easy to load, save and delete resources. It gives also support to paging, filtering and sorting.
3
+ The @ngdux/list uses ngrx/store to give you a full state to make easy to load, save and delete resources. It gives also support to paging, filtering and sorting.
4
+ It was created to reduce the ngrx/store boilerplate code
5
+
6
+ ## Installation
7
+
8
+ npm install @ngdux/list
4
9
 
5
10
  Example:
6
11
 
7
- ## Option 1
12
+ ## Option 1 - Full state
8
13
 
9
- ### Full state
14
+ https://github.com/allanartuso/ngdux/tree/master/libs/demo/data-access/properties/src/lib/%2Bstate/properties
15
+
16
+ ### State
10
17
 
11
18
  ```
12
19
  import { UserDto } from '@demo/demo/data-model/users';
@@ -22,7 +29,24 @@ export const {
22
29
  } = createListState<UserDto, ErrorDto>(USERS_FEATURE_KEY);
23
30
  ```
24
31
 
25
- ## Option 2
32
+ ### Facade
33
+
34
+ ```
35
+ import { Injectable } from '@angular/core';
36
+ import { AbstractListFacade } from '@ngdux/list';
37
+ import { Store } from '@ngrx/store';
38
+ import { usersActions, usersSelectors } from './users.state';
39
+ import { User, Error } from './models';
40
+
41
+ @Injectable()
42
+ export class UsersFacade extends AbstractListFacade<User, Error> {
43
+ constructor(store: Store) {
44
+ super(store, usersActions, usersSelectors);
45
+ }
46
+ }
47
+ ```
48
+
49
+ ## Option 2 - Separated creators for actions, reducer and selectors
26
50
 
27
51
  ### Actions
28
52
 
@@ -30,7 +54,7 @@ export const {
30
54
  import { createListActions } from '@ngdux/list';
31
55
  import { User, Error } from './models';
32
56
 
33
- export const listActions = createListActions<User, Error>('Users');
57
+ export const usersActions = createListActions<User, Error>('Users');
34
58
  ```
35
59
 
36
60
  ### Reducer
@@ -39,12 +63,12 @@ export const listActions = createListActions<User, Error>('Users');
39
63
  import { createListEntityAdapter, createListReducer, ListState } from '@ngdux/list';
40
64
  import { Action } from '@ngrx/store';
41
65
  import { User, Error } from './models';
42
- import { listActions } from './users.actions';
66
+ import { usersActions } from './users.actions';
43
67
 
44
68
  export const USERS_FEATURE_KEY = 'users';
45
69
  export const entityAdapter = createListEntityAdapter<User>();
46
70
 
47
- const reducer = createListReducer<User, Error>(entityAdapter, listActions);
71
+ const reducer = createListReducer<User, Error>(entityAdapter, usersActions);
48
72
 
49
73
  export function usersReducer(state: ListState<User, Error>, action: Action): ListState<User, Error> {
50
74
  return reducer(state, action);
@@ -61,7 +85,82 @@ import { entityAdapter, USERS_FEATURE_KEY } from './users.reducer';
61
85
 
62
86
  const getState = createFeatureSelector<ListState<User, Error>>(USERS_FEATURE_KEY);
63
87
 
64
- export const listSelectors = createListSelectors(entityAdapter, getState);
88
+ export const usersSelectors = createListSelectors(entityAdapter, getState);
89
+ ```
90
+
91
+ ### Facade
92
+
93
+ ```
94
+ import { Injectable } from '@angular/core';
95
+ import { AbstractListFacade } from '@ngdux/list';
96
+ import { Store } from '@ngrx/store';
97
+ import { usersActions } from './users.actions';
98
+ import { usersSelectors } from './users.selectors';
99
+
100
+ @Injectable()
101
+ export class UsersFacade extends AbstractListFacade<User, Error> {
102
+ constructor(store: Store) {
103
+ super(store, userActions, usersSelectors);
104
+ }
105
+ }
106
+ ```
107
+
108
+ ## Option 3 - Dynamic feature key
109
+
110
+ https://github.com/allanartuso/ngdux/tree/master/libs/demo/data-access/users/src/lib/%2Bstate/users
111
+
112
+ ### Reducer manager service
113
+
114
+ ```
115
+ import { Injectable } from '@angular/core';
116
+ import { User, Error } from '.../models';
117
+ import { AbstractListReducerManager } from '@ngdux/list';
118
+
119
+ @Injectable()
120
+ export class UsersReducerManager extends AbstractListReducerManager<User, Error> {}
121
+ ```
122
+
123
+ ### Facade
124
+
125
+ ```
126
+ import { Injectable } from '@angular/core';
127
+ import { AbstractListFacade } from '@ngdux/list';
128
+ import { Store } from '@ngrx/store';
129
+ import { UsersReducerManager } from './users-state.service';
130
+
131
+ @Injectable()
132
+ export class UsersFacade extends AbstractListFacade<User, Error> {
133
+ constructor(store: Store, usersReducerManager: UsersReducerManager) {
134
+ super(store, usersReducerManager.actions, usersReducerManager.selectors);
135
+ }
136
+ }
137
+
138
+ ```
139
+
140
+ ### Module
141
+
142
+ ```
143
+ import { ModuleWithProviders, NgModule } from '@angular/core';
144
+ import { LIST_FEATURE_KEY } from '@ngdux/list';
145
+ import { UsersReducerManager } from './+state/users/users-state.service';
146
+ import { UsersFacade } from './+state/users/users.facade';
147
+
148
+ @NgModule({
149
+ providers: [
150
+ UsersReducerManager,
151
+ UsersFacade
152
+ ]
153
+ })
154
+ export class UsersModule {
155
+ static config(listFeatureKey: string): ModuleWithProviders<UsersModule> {
156
+ return {
157
+ ngModule: UsersModule,
158
+ providers: [
159
+ { provide: LIST_FEATURE_KEY, useValue: listFeatureKey },
160
+ ]
161
+ };
162
+ }
163
+ }
65
164
  ```
66
165
 
67
166
  ## Effects
@@ -73,8 +172,8 @@ import { AbstractListEffects } from '@ngdux/list';
73
172
  import { Actions } from '@ngrx/effects';
74
173
  import { Store } from '@ngrx/store';
75
174
  import { UserService } from '../../services/user.service';
76
- import { listActions } from './users.actions';
77
- import { listSelectors } from './users.selectors';
175
+ import { usersActions } from './users.actions';
176
+ import { usersSelectors } from './users.selectors';
78
177
  import { User, Error } from './models';
79
178
 
80
179
  @Injectable()
@@ -91,7 +190,7 @@ export class UsersEffects extends AbstractListEffects<User, Error> {
91
190
  usersService: UserService,
92
191
  notificationService: NotificationService
93
192
  ) {
94
- super(actions$, store, usersService, listActions, listSelectors, notificationService);
193
+ super(actions$, store, usersService, usersActions, usersSelectors, notificationService);
95
194
  }
96
195
  }
97
196
  ```
package/package.json CHANGED
@@ -1,12 +1,22 @@
1
1
  {
2
2
  "name": "@ngdux/list",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:allanartuso/ngdux.git",
7
7
  "directory": "/libs/ngdux/util/store/list"
8
8
  },
9
9
  "homepage": "https://github.com/allanartuso/ngdux/tree/master/libs/ngdux/util/store/list#readme",
10
+ "default": {
11
+ "name": "@ngdux/list",
12
+ "version": "1.1.0",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git@github.com:allanartuso/ngdux.git",
16
+ "directory": "/libs/ngdux/util/store/list"
17
+ },
18
+ "homepage": "https://github.com/allanartuso/ngdux/tree/master/libs/ngdux/util/store/list#readme"
19
+ },
10
20
  "module": "fesm2015/ngdux-list.mjs",
11
21
  "es2020": "fesm2020/ngdux-list.mjs",
12
22
  "esm2020": "esm2020/ngdux-list.mjs",
@@ -31,9 +41,9 @@
31
41
  "tslib": "^2.3.0"
32
42
  },
33
43
  "peerDependencies": {
34
- "@ngdux/data-model-common": "1.1.0",
44
+ "@ngdux/data-model-common": "1.1.1",
35
45
  "@angular/core": "15.2.9",
36
- "@ngdux/store-common": "1.1.0",
46
+ "@ngdux/store-common": "1.1.1",
37
47
  "@ngrx/entity": "15.3.0"
38
48
  }
39
49
  }