├── .gitignore
├── .idea
├── .gitignore
├── gentleman-state-manager.iml
├── inspectionProfiles
│ └── Project_Default.xml
├── modules.xml
└── vcs.xml
├── LICENSE
├── README.md
├── angular.json
├── dist
└── gentleman-state-manager
│ ├── README.md
│ ├── bundles
│ ├── gentleman-state-manager-lib.umd.js
│ └── gentleman-state-manager-lib.umd.js.map
│ ├── esm2015
│ ├── gentleman-state-manager-lib.js
│ ├── lib
│ │ ├── gentleman-state-manager.module.js
│ │ ├── models
│ │ │ ├── gentleman-state-object.js
│ │ │ ├── public-api.js
│ │ │ ├── source-of-truth.js
│ │ │ ├── state.js
│ │ │ └── utils.js
│ │ ├── public-api.js
│ │ ├── services
│ │ │ ├── gentleman-state.service.js
│ │ │ └── public-api.js
│ │ └── utils
│ │ │ ├── functionalities.js
│ │ │ └── public-api.js
│ └── public-api.js
│ ├── fesm2015
│ ├── gentleman-state-manager-lib.js
│ └── gentleman-state-manager-lib.js.map
│ ├── gentleman-state-manager-lib.d.ts
│ ├── gentleman-state-manager-lib.d.ts.map
│ ├── lib
│ ├── gentleman-state-manager.module.d.ts
│ ├── gentleman-state-manager.module.d.ts.map
│ ├── models
│ │ ├── gentleman-state-object.d.ts
│ │ ├── gentleman-state-object.d.ts.map
│ │ ├── public-api.d.ts
│ │ ├── public-api.d.ts.map
│ │ ├── source-of-truth.d.ts
│ │ ├── source-of-truth.d.ts.map
│ │ ├── state.d.ts
│ │ ├── state.d.ts.map
│ │ ├── utils.d.ts
│ │ └── utils.d.ts.map
│ ├── public-api.d.ts
│ ├── public-api.d.ts.map
│ ├── services
│ │ ├── gentleman-state.service.d.ts
│ │ ├── gentleman-state.service.d.ts.map
│ │ ├── public-api.d.ts
│ │ └── public-api.d.ts.map
│ └── utils
│ │ ├── functionalities.d.ts
│ │ ├── functionalities.d.ts.map
│ │ ├── public-api.d.ts
│ │ └── public-api.d.ts.map
│ ├── package.json
│ ├── public-api.d.ts
│ └── public-api.d.ts.map
├── package.json
├── projects
└── gentleman-state-manager
│ ├── README.md
│ ├── karma.conf.js
│ ├── ng-package.json
│ ├── package.json
│ ├── src
│ ├── lib
│ │ ├── gentleman-state-manager.module.ts
│ │ ├── models
│ │ │ ├── gentleman-state-object.ts
│ │ │ ├── public-api.ts
│ │ │ ├── source-of-truth.ts
│ │ │ ├── state.ts
│ │ │ └── utils.ts
│ │ ├── public-api.ts
│ │ ├── services
│ │ │ ├── gentleman-state.service.ts
│ │ │ └── public-api.ts
│ │ └── utils
│ │ │ ├── functionalities.ts
│ │ │ └── public-api.ts
│ ├── public-api.ts
│ └── test.ts
│ ├── tsconfig.lib.json
│ ├── tsconfig.lib.prod.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── tsconfig.json
├── tslint.json
└── yarn.lock
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 |
--------------------------------------------------------------------------------
/.idea/gentleman-state-manager.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Alan Buscaglia
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Gentleman State Manager
2 |
3 | This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.0.5.
4 |
5 | ## Description
6 |
7 | Hi everyone ! this is a super easy and comfortable way of using reactive programming to manage the state of your application.
8 | This library is based on Rxjs Behaviour Subject observables to manage the different states of your application using the concept of a single source of truth.
9 |
10 | First...Let's learn some things !
11 |
12 | Reactive programming is the concept of developing code where different entities are watching trough an information channel for data to pass, and when it does,
13 | each entity will "react" to that situation doing their business logic.
14 |
15 | Imagine an empty tube with 3 holes in it, at each hole we have a person looking trough it and waiting for a little ball to pass. Because each person is different,
16 | they will see different aspects of the ball. For example, one can see that the ball is red, another that the ball is bouncing a little when it's passing trough
17 | ...or even that maybe it's not a ball at all !.
18 |
19 | That's exactly what reactive programming is ! we have an information channel (observables) containing the data that is passing trough it,
20 | and on the other hand we have entities (the angular components for example) that will be subscribed and waiting for that information to pass ...and when it does,
21 | they will react to it doing what ever business logic we coded for them.
22 |
23 | Redux, Ngrx/store, etc. are libraries that provide tools to manage the state of the application using the concept of "A Single Source Of Truth", these means that
24 | the whole information of the app will be contained inside a "store", a place where you can access useful and up to date information. Each time a change happens
25 | inside your application, information wise, the store will be updated with the latest changes. So you don't need to call the back end again for an update if not needed and also
26 | all entities that are watching the store's states will be automatically alerted of the change.
27 |
28 | Rxjs is a library containing a lot of amazing tools to manage these information channels, these provide the ability to combine and modify observables with the inclusion of
29 | new kinds of observables to use, each one with their own functionalities.
30 |
31 | We are going to use Behaviour Subjects a lot in this case, it's an observable that will always contain the last data that passed trough it....which is amazing for what we want to do !
32 | When ever we send information trough the Behaviour Subject, even if an entity subscribes AFTER the information has been sent, it will receive the latest data ! so we don't loose anything.
33 |
34 | The main concept of Gentleman State Manager, is providing an useful way to manage the state of your application, using understandable and cristal clear tools like Rxjs to do so.
35 | In short, we create an array of observables identified by their key, that can be increased in size by each module (so yes, we use lazy loading !) to manage the information
36 | that passes trough the different entities of your Angular application.
37 |
38 | ## How to use
39 |
40 | 1- Create an object using the SourceOfTruthInitiate class provided by the library. I recommend having a state.ts per module, representing the state interfaces and properties :
41 |
42 | ```
43 | state.ts for Root ( AppModule ):
44 |
45 | export interface FirstState {
46 | stateProperty: string | null;
47 | }
48 |
49 | export enum FirstStateProperties {
50 | STATEPROPERTY: 'stateProperty'
51 | }
52 |
53 | export enum StoreKeys {
54 | FIRSTSTATE: 'firstState'
55 | }
56 |
57 | AppModule:
58 |
59 | const sourceOfTruthInitiate: SourceOfTruthInitiate[] = [
60 | {
61 | key: StoreKeys.FIRSTSTATE,
62 | state: {
63 | stateProperty: 'your state property value'
64 | },
65 | stateProperties: FirstStateProperties
66 | }
67 | ];
68 | ```
69 |
70 | - key: represents the key to access the proper observable that we want to use.
71 | - state: the empty state of the object that will pass trough the observable.
72 | - stateProperties: the properties of the object, we are going to use it to access the information without ambiguities.
73 |
74 | 2- import GentlemanStateManagerModule inside your application in the following way:
75 |
76 | ```
77 | @NgModule({
78 | imports: [
79 | ...
80 | GentlemanStateManagerModule.forRoot(sourceOfTruthInitiate)
81 | ...
82 | ]
83 | })
84 | export class AppModule {}
85 | ```
86 |
87 | 3- use our apis to access the information or send something new !
88 |
89 | Example:
90 |
91 | ```
92 | export class OverviewMetricComponent implements OnDestroy {
93 | constructor(gentlemanStateManager: GentlemanStateService) {
94 | console.log(gentlemanStateManager.getEntity(StoreKeys.FIRSTSTATE).getPropertyFromState(FirstStateProperties.STATEPROPERTY));
95 | }
96 | }
97 | ```
98 |
99 | 4- to lazy load more observables just do the same functionality as in the app module, but in the constructor of your lazy loaded one.
100 |
101 | Example:
102 |
103 | ```
104 | state.ts for Root ( AppModule ):
105 |
106 | ...
107 | export enum StoreKeys {
108 | FIRSTSTATE: 'firstState',
109 | LAZYLOADEDSTATE: 'lazyLoadedState' // we add the new state key
110 | }
111 | ...
112 |
113 | state.ts of your lazy loaded module:
114 |
115 | export interface LazyLoadedState {
116 | lazyLoadedStateProperty: string | null;
117 | }
118 |
119 | export enum LazyLoadedStateProperties {
120 | LAZYLOADEDSTATEPROPERTY: 'lazyLoadedStateProperty'
121 | }
122 |
123 | const sourceOfTruthInitiate: SourceOfTruthInitiate[] = [
124 | {
125 | key: StoreKeys.LAZYLOADEDSTATE,
126 | state: {
127 | lazyLoadedStateProperty: 'Your Lazy Loaded State Property'
128 | },
129 | stateProperties: LazyLoadedStateProperties
130 | }
131 | ];
132 |
133 | @NgModule({
134 | ...
135 | })
136 | export class LazyLoadedModule {
137 | constructor(gentlemanStateService: GentlemanStateService) {
138 | sourceOfTruthInitiate.forEach(state => gentlemanStateService.createObservable(state.key, state.state, state.stateProperties));
139 | }
140 | }
141 |
142 | ```
143 |
144 | ## Api
145 |
146 | ### Array Of Observables Management :
147 |
148 | createObservable
149 |
150 | ```
151 | /**
152 | * @desc it creates and observable and adds it to the observable array.
153 | * @param key: the key to be used to represent the observable item inside the array
154 | * @param state: the state of the observable, the object that represents what the observable is going to contain
155 | * @return void
156 | */
157 | createObservable(key: string, state: any, stateProperties: StateProperties): void
158 | ```
159 |
160 | getEntity
161 |
162 | ```
163 | /**
164 | * @desc it returns the selected observable using the provided key.
165 | * @param key - the key to be used to represent the observable item inside the array
166 | * @return GentlemanStateObject
167 | */
168 | getEntity(key: string): GentlemanStateObject
169 | ```
170 |
171 | destroyObservable
172 |
173 | ```
174 | /**
175 | * @desc it destroys an object from the observable array.
176 | * @param key - the key to be used to represent the observable item inside the array
177 | * @return void
178 | */
179 | destroyObservable(key: string): void
180 | ```
181 |
182 | ### GentlemanStateObject :
183 |
184 | getObservable
185 |
186 | ```
187 | /**
188 | * @desc returns the observable that contains the state for async operations - it listens for changes
189 | * @return Observable
190 | */
191 | getObservable(): Observable
192 | ```
193 |
194 | getStateProperties
195 |
196 | ```
197 | /**
198 | * @desc returns the state properties object
199 | * @return StateProperties
200 | */
201 | getStateProperties(): StateProperties
202 | ```
203 |
204 | unsubscribe (use it when you are destroying the main component of your module)
205 |
206 | ```
207 | /**
208 | * @desc unsubscribes from the observable
209 | * @return void
210 | */
211 | unsubscribe(): void
212 | ```
213 |
214 | getStateSnapshot
215 |
216 | ```
217 | /**
218 | * @desc returns the value of the state at the time of the call
219 | * @return any
220 | */
221 | getStateSnapshot(): any
222 | ```
223 |
224 | getPropertyFromState
225 |
226 | ```
227 | /**
228 | * @desc returns the value of a property of the state at the time of the call
229 | * @param property - the name of the requested property
230 | * @return any
231 | */
232 | getPropertyFromState(property: string): any
233 | ```
234 |
235 | getPropertyFromObservable
236 |
237 | ```
238 | /**
239 | * @desc returns the value of a property of the state for async operations - it listens for changes
240 | * @param property - the name of the requested property
241 | * @return Observable
242 | */
243 | getPropertyFromObservable(property: string): Observable
244 | ```
245 |
246 | setObservableValues
247 |
248 | ```
249 | /**
250 | * @desc sets the value for a certain property inside the state, triggers an async event
251 | * @param value - the value for the requested property
252 | * @param property - the name of the requested property
253 | * @param emit - if true it will trigger an async event
254 | * @return void
255 | */
256 | setObservableValues(value: any, property: string | null = null, emit = true): void
257 | ```
258 |
259 | setStateValues
260 |
261 | ```
262 | /**
263 | * @desc sets the value for a certain property inside the state, doesn't triggers an async event
264 | * @param value - the value for the requested property
265 | * @param property - the name of the requested property, if no property it will try to patch the values into the state
266 | * @return void
267 | */
268 | setStateValues(value: any, property: string | null): void
269 | ```
270 |
271 | resetState
272 |
273 | ```
274 | /**
275 | * @desc resets the state
276 | * @return void
277 | */
278 | resetState(): void
279 | ```
280 |
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "gentleman-state-manager": {
7 | "projectType": "library",
8 | "root": "projects/gentleman-state-manager",
9 | "sourceRoot": "projects/gentleman-state-manager/src",
10 | "prefix": "lib",
11 | "architect": {
12 | "build": {
13 | "builder": "@angular-devkit/build-angular:ng-packagr",
14 | "options": {
15 | "tsConfig": "projects/gentleman-state-manager/tsconfig.lib.json",
16 | "project": "projects/gentleman-state-manager/ng-package.json"
17 | },
18 | "configurations": {
19 | "production": {
20 | "tsConfig": "projects/gentleman-state-manager/tsconfig.lib.prod.json"
21 | }
22 | }
23 | },
24 | "test": {
25 | "builder": "@angular-devkit/build-angular:karma",
26 | "options": {
27 | "main": "projects/gentleman-state-manager/src/test.ts",
28 | "tsConfig": "projects/gentleman-state-manager/tsconfig.spec.json",
29 | "karmaConfig": "projects/gentleman-state-manager/karma.conf.js"
30 | }
31 | },
32 | "lint": {
33 | "builder": "@angular-devkit/build-angular:tslint",
34 | "options": {
35 | "tsConfig": [
36 | "projects/gentleman-state-manager/tsconfig.lib.json",
37 | "projects/gentleman-state-manager/tsconfig.spec.json"
38 | ],
39 | "exclude": [
40 | "**/node_modules/**"
41 | ]
42 | }
43 | }
44 | }
45 | }},
46 | "defaultProject": "gentleman-state-manager"
47 | }
48 |
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/README.md:
--------------------------------------------------------------------------------
1 | # Gentleman State Manager
2 |
3 | This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.0.5.
4 |
5 | ## Description
6 |
7 | Hi everyone ! this is a super easy and comfortable way of using reactive programming to manage the state of your application.
8 | This library is based on Rxjs Behaviour Subject observables to manage the different states of your application using the concept of a single source of truth.
9 |
10 | First...Let's learn some things !
11 |
12 | Reactive programming is the concept of developing code where different entities are watching trough an information channel for data to pass, and when it does,
13 | each entity will "react" to that situation doing their business logic.
14 |
15 | Imagine an empty tube with 3 holes in it, at each hole we have a person looking trough it and waiting for a little ball to pass. Because each person is different,
16 | they will see different aspects of the ball. For example, one can see that the ball is red, another that the ball is bouncing a little when it's passing trough
17 | ...or even that maybe it's not a ball at all !.
18 |
19 | That's exactly what reactive programming is ! we have an information channel (observables) containing the data that is passing trough it,
20 | and on the other hand we have entities (the angular components for example) that will be subscribed and waiting for that information to pass ...and when it does,
21 | they will react to it doing what ever business logic we coded for them.
22 |
23 | Redux, Ngrx/store, etc. are libraries that provide tools to manage the state of the application using the concept of "A Single Source Of Truth", these means that
24 | the whole information of the app will be contained inside a "store", a place where you can access useful and up to date information. Each time a change happens
25 | inside your application, information wise, the store will be updated with the latest changes. So you don't need to call the back end again for an update if not needed and also
26 | all entities that are watching the store's states will be automatically alerted of the change.
27 |
28 | Rxjs is a library containing a lot of amazing tools to manage these information channels, these provide the ability to combine and modify observables with the inclusion of
29 | new kinds of observables to use, each one with their own functionalities.
30 |
31 | We are going to use Behaviour Subjects a lot in this case, it's an observable that will always contain the last data that passed trough it....which is amazing for what we want to do !
32 | When ever we send information trough the Behaviour Subject, even if an entity subscribes AFTER the information has been sent, it will receive the latest data ! so we don't loose anything.
33 |
34 | The main concept of Gentleman State Manager, is providing an useful way to manage the state of your application, using understandable and cristal clear tools like Rxjs to do so.
35 | In short, we create an array of observables identified by their key, that can be increased in size by each module (so yes, we use lazy loading !) to manage the information
36 | that passes trough the different entities of your Angular application.
37 |
38 | ## How to use
39 |
40 | 1- Create an object using the SourceOfTruthInitiate class provided by the library. I recommend having a state.ts per module, representing the state interfaces and properties :
41 |
42 | ```
43 | state.ts for Root ( AppModule ):
44 |
45 | export interface FirstState {
46 | stateProperty: string | null;
47 | }
48 |
49 | export enum FirstStateProperties {
50 | STATEPROPERTY: 'stateProperty'
51 | }
52 |
53 | export enum StoreKeys {
54 | FIRSTSTATE: 'firstState'
55 | }
56 |
57 | AppModule:
58 |
59 | const sourceOfTruthInitiate: SourceOfTruthInitiate[] = [
60 | {
61 | key: StoreKeys.FIRSTSTATE,
62 | state: {
63 | stateProperty: 'your state property value'
64 | },
65 | stateProperties: FirstStateProperties
66 | }
67 | ];
68 | ```
69 |
70 | - key: represents the key to access the proper observable that we want to use.
71 | - state: the empty state of the object that will pass trough the observable.
72 | - stateProperties: the properties of the object, we are going to use it to access the information without ambiguities.
73 |
74 | 2- import GentlemanStateManagerModule inside your application in the following way:
75 |
76 | ```
77 | @NgModule({
78 | imports: [
79 | ...
80 | GentlemanStateManagerModule.forRoot(sourceOfTruthInitiate)
81 | ...
82 | ]
83 | })
84 | export class AppModule {}
85 | ```
86 |
87 | 3- use our apis to access the information or send something new !
88 |
89 | Example:
90 |
91 | ```
92 | export class OverviewMetricComponent implements OnDestroy {
93 | constructor(gentlemanStateManager: GentlemanStateService) {
94 | console.log(gentlemanStateManager.getEntity(StoreKeys.FIRSTSTATE).getPropertyFromState(FirstStateProperties.STATEPROPERTY));
95 | }
96 | }
97 | ```
98 |
99 | 4- to lazy load more observables just do the same functionality as in the app module, but in the constructor of your lazy loaded one.
100 |
101 | Example:
102 |
103 | ```
104 | state.ts for Root ( AppModule ):
105 |
106 | ...
107 | export enum StoreKeys {
108 | FIRSTSTATE: 'firstState',
109 | LAZYLOADEDSTATE: 'lazyLoadedState' // we add the new state key
110 | }
111 | ...
112 |
113 | state.ts of your lazy loaded module:
114 |
115 | export interface LazyLoadedState {
116 | lazyLoadedStateProperty: string | null;
117 | }
118 |
119 | export enum LazyLoadedStateProperties {
120 | LAZYLOADEDSTATEPROPERTY: 'lazyLoadedStateProperty'
121 | }
122 |
123 | const sourceOfTruthInitiate: SourceOfTruthInitiate[] = [
124 | {
125 | key: StoreKeys.LAZYLOADEDSTATE,
126 | state: {
127 | lazyLoadedStateProperty: 'Your Lazy Loaded State Property'
128 | },
129 | stateProperties: LazyLoadedStateProperties
130 | }
131 | ];
132 |
133 | @NgModule({
134 | ...
135 | })
136 | export class LazyLoadedModule {
137 | constructor(gentlemanStateService: GentlemanStateService) {
138 | sourceOfTruthInitiate.forEach(state => gentlemanStateService.createObservable(state.key, state.state, state.stateProperties));
139 | }
140 | }
141 |
142 | ```
143 |
144 | ## Api
145 |
146 | ### Array Of Observables Management :
147 |
148 | createObservable
149 |
150 | ```
151 | /**
152 | * @desc it creates and observable and adds it to the observable array.
153 | * @param key: the key to be used to represent the observable item inside the array
154 | * @param state: the state of the observable, the object that represents what the observable is going to contain
155 | * @return void
156 | */
157 | createObservable(key: string, state: any, stateProperties: StateProperties): void
158 | ```
159 |
160 | getEntity
161 |
162 | ```
163 | /**
164 | * @desc it returns the selected observable using the provided key.
165 | * @param key - the key to be used to represent the observable item inside the array
166 | * @return GentlemanStateObject
167 | */
168 | getEntity(key: string): GentlemanStateObject
169 | ```
170 |
171 | destroyObservable
172 |
173 | ```
174 | /**
175 | * @desc it destroys an object from the observable array.
176 | * @param key - the key to be used to represent the observable item inside the array
177 | * @return void
178 | */
179 | destroyObservable(key: string): void
180 | ```
181 |
182 | ### GentlemanStateObject :
183 |
184 | getObservable
185 |
186 | ```
187 | /**
188 | * @desc returns the observable that contains the state for async operations - it listens for changes
189 | * @return Observable
190 | */
191 | getObservable(): Observable
192 | ```
193 |
194 | getStateProperties
195 |
196 | ```
197 | /**
198 | * @desc returns the state properties object
199 | * @return StateProperties
200 | */
201 | getStateProperties(): StateProperties
202 | ```
203 |
204 | unsubscribe (use it when you are destroying the main component of your module)
205 |
206 | ```
207 | /**
208 | * @desc unsubscribes from the observable
209 | * @return void
210 | */
211 | unsubscribe(): void
212 | ```
213 |
214 | getStateSnapshot
215 |
216 | ```
217 | /**
218 | * @desc returns the value of the state at the time of the call
219 | * @return any
220 | */
221 | getStateSnapshot(): any
222 | ```
223 |
224 | getPropertyFromState
225 |
226 | ```
227 | /**
228 | * @desc returns the value of a property of the state at the time of the call
229 | * @param property - the name of the requested property
230 | * @return any
231 | */
232 | getPropertyFromState(property: string): any
233 | ```
234 |
235 | getPropertyFromState
236 |
237 | ```
238 | /**
239 | * @desc returns the value of a property of the state at the time of the call
240 | * @param property - the name of the requested property
241 | * @return any
242 | */
243 | getPropertyFromState(property: string): any
244 | ```
245 |
246 | getPropertyFromObservable
247 |
248 | ```
249 | /**
250 | * @desc returns the value of a property of the state for async operations - it listens for changes
251 | * @param property - the name of the requested property
252 | * @return Observable
253 | */
254 | getPropertyFromObservable(property: string): Observable
255 | ```
256 |
257 | setObservableValues
258 |
259 | ```
260 | /**
261 | * @desc sets the value for a certain property inside the state, triggers an async event
262 | * @param value - the value for the requested property
263 | * @param property - the name of the requested property
264 | * @param emit - if true it will trigger an async event
265 | * @return void
266 | */
267 | setObservableValues(value: any, property: string | null = null, emit = true): void
268 | ```
269 |
270 | setStateValues
271 |
272 | ```
273 | /**
274 | * @desc sets the value for a certain property inside the state, doesn't triggers an async event
275 | * @param value - the value for the requested property
276 | * @param property - the name of the requested property, if no property it will try to patch the values into the state
277 | * @return void
278 | */
279 | setStateValues(value: any, property: string | null): void
280 | ```
281 |
282 | resetState
283 |
284 | ```
285 | /**
286 | * @desc resets the state
287 | * @return void
288 | */
289 | resetState(): void
290 | ```
291 |
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/bundles/gentleman-state-manager-lib.umd.js:
--------------------------------------------------------------------------------
1 | (function (global, factory) {
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators')) :
3 | typeof define === 'function' && define.amd ? define('gentleman-state-manager-lib', ['exports', '@angular/core', 'rxjs', 'rxjs/operators'], factory) :
4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['gentleman-state-manager-lib'] = {}, global.ng.core, global.rxjs, global.rxjs.operators));
5 | }(this, (function (exports, i0, rxjs, operators) { 'use strict';
6 |
7 | function _interopNamespace(e) {
8 | if (e && e.__esModule) return e;
9 | var n = Object.create(null);
10 | if (e) {
11 | Object.keys(e).forEach(function (k) {
12 | if (k !== 'default') {
13 | var d = Object.getOwnPropertyDescriptor(e, k);
14 | Object.defineProperty(n, k, d.get ? d : {
15 | enumerable: true,
16 | get: function () {
17 | return e[k];
18 | }
19 | });
20 | }
21 | });
22 | }
23 | n['default'] = e;
24 | return Object.freeze(n);
25 | }
26 |
27 | var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28 |
29 | /**
30 | * @desc checks if the condition is met and returns its value
31 | * @param condition - the condition to check
32 | * @param errorMessage - the error message to be shown if the condition is not met
33 | * @return any
34 | */
35 | function checkIfConditionMet(condition, errorMessage) {
36 | var conditionMet = condition();
37 | if (!conditionMet.met) {
38 | console.error(errorMessage);
39 | throw Error(errorMessage);
40 | }
41 | return conditionMet.value;
42 | }
43 |
44 | var GentlemanStateObject = /** @class */ (function () {
45 | function GentlemanStateObject(state, stateProperties) {
46 | this.stateProperties = {};
47 | this.state = state;
48 | this.stateProperties = stateProperties;
49 | this.observableSubject = new rxjs.BehaviorSubject(state);
50 | }
51 | /**
52 | * @desc returns the observable that contains the state for async operations - it listens for changes
53 | * @return Observable
54 | */
55 | GentlemanStateObject.prototype.getObservable = function () {
56 | return this.observableSubject.asObservable();
57 | };
58 | /**
59 | * @desc returns the state properties object
60 | * @return StateProperties
61 | */
62 | GentlemanStateObject.prototype.getStateProperties = function () {
63 | return this.stateProperties;
64 | };
65 | /**
66 | * @desc unsubscribes from the observable
67 | * @return void
68 | */
69 | GentlemanStateObject.prototype.unsubscribe = function () {
70 | this.observableSubject.unsubscribe();
71 | };
72 | /**
73 | * @desc returns the value of the state at the time of the call
74 | * @return any
75 | */
76 | GentlemanStateObject.prototype.getStateSnapshot = function () {
77 | return Object.assign({}, this.state);
78 | };
79 | /**
80 | * @desc returns the value of a property of the state at the time of the call
81 | * @param property - the name of the requested property
82 | * @return any
83 | */
84 | GentlemanStateObject.prototype.getPropertyFromState = function (property) {
85 | return this.state[property];
86 | };
87 | /**
88 | * @desc returns the value of a property of the state for async operations - it listens for changes
89 | * @param property - the name of the requested property
90 | * @return Observable
91 | */
92 | GentlemanStateObject.prototype.getPropertyFromObservable = function (property) {
93 | var _this = this;
94 | return this.getObservable().pipe(operators.map(function (s) { return _this.checkIfPropertyExists(s, property); }));
95 | };
96 | /**
97 | * @desc sets the value for a certain property inside the state, triggers an async event
98 | * @param value - the value for the requested property
99 | * @param property - the name of the requested property
100 | * @param emit - if true it will trigger an async event
101 | * @return void
102 | */
103 | GentlemanStateObject.prototype.setObservableValues = function (value, property, emit) {
104 | if (property === void 0) { property = null; }
105 | if (emit === void 0) { emit = true; }
106 | this.setStateValues(value, property);
107 | if (emit) {
108 | this.observableSubject.next(this.state);
109 | }
110 | };
111 | /**
112 | * @desc sets the value for a certain property inside the state, doesn't triggers an async event
113 | * @param value - the value for the requested property
114 | * @param property - the name of the requested property, if no property it will try to patch the values into the state
115 | * @return void
116 | */
117 | GentlemanStateObject.prototype.setStateValues = function (value, property) {
118 | if (property && this.checkIfPropertyExists(this.state, property) !== undefined) {
119 | this.state[property] = value;
120 | }
121 | else {
122 | this.state = Object.assign(Object.assign({}, this.state), value);
123 | }
124 | };
125 | /**
126 | * @desc resets the state
127 | * @return void
128 | */
129 | GentlemanStateObject.prototype.resetState = function () {
130 | this.state = {};
131 | };
132 | /**
133 | * @desc checks if the selected property exists inside the state
134 | * @param state - the state of the observable, the object that represents what the observable is going to contain
135 | * @param property - the selected property
136 | * @return any
137 | */
138 | GentlemanStateObject.prototype.checkIfPropertyExists = function (state, property) {
139 | var condition = function () {
140 | return { met: state.hasOwnProperty(property), value: state[property] };
141 | };
142 | return checkIfConditionMet(function () { return condition(); }, 'Selected property not found ! check if the key is correct and exists');
143 | };
144 | return GentlemanStateObject;
145 | }());
146 |
147 | var GentlemanStateService = /** @class */ (function () {
148 | function GentlemanStateService(sourceOfTruthKeys) {
149 | var _this = this;
150 | this.observerArray = new Map();
151 | sourceOfTruthKeys.forEach(function (k) {
152 | var state = k.state, stateProperties = k.stateProperties;
153 | _this.createObservable(k.key, state, stateProperties);
154 | });
155 | }
156 | /**
157 | * @desc it checks if the searched object exists, if not it throws an errors and stops the execution.
158 | * @param gentlemanObject - GentlemanStateObject | undefined
159 | * @return GentlemanStateObject
160 | */
161 | GentlemanStateService.checkIfFound = function (gentlemanObject) {
162 | var condition = function () {
163 | return { met: !!gentlemanObject, value: gentlemanObject };
164 | };
165 | return checkIfConditionMet(function () { return condition(); }, "Observable item not found ! check if the key is correct and exists");
166 | };
167 | /**
168 | * @desc it creates and observable and adds it to the observable array.
169 | * @param key - the key to be used to represent the observable item inside the array
170 | * @param state - the state of the observable, the object that represents what the observable is going to contain
171 | * @param stateProperties - the properties of the state
172 | * @return void
173 | */
174 | GentlemanStateService.prototype.createObservable = function (key, state, stateProperties) {
175 | var found = this.observerArray.has(key);
176 | if (found) {
177 | console.log("the key : " + key + ", already exists as an entity so it will be ignored");
178 | }
179 | else {
180 | var gentlemanObject = new GentlemanStateObject(state, stateProperties);
181 | this.observerArray.set(key, gentlemanObject);
182 | }
183 | };
184 | /**
185 | * @desc it returns the selected observable using the provided key.
186 | * @param key - the key to be used to represent the observable item inside the array
187 | * @return GentlemanStateObject
188 | */
189 | GentlemanStateService.prototype.getEntity = function (key) {
190 | var observableArrayItem = GentlemanStateService.checkIfFound(this.observerArray.get(key));
191 | return observableArrayItem;
192 | };
193 | /**
194 | * @desc it emits a new value into the selected observable using the provided key.
195 | * @param key - the key to be used to represent the observable item inside the array
196 | * @param data - the data to be emitted inside the selected observable
197 | * @return void
198 | */
199 | GentlemanStateService.prototype.emitValue = function (key, data) {
200 | var observableArrayItem = GentlemanStateService.checkIfFound(this.observerArray.get(key));
201 | observableArrayItem.setObservableValues(data);
202 | };
203 | /**
204 | * @desc it destroys an object from the observable array.
205 | * @param key - the key to be used to represent the observable item inside the array
206 | * @return void
207 | */
208 | GentlemanStateService.prototype.destroyObservable = function (key) {
209 | var selectedObservable = GentlemanStateService.checkIfFound(this.observerArray.get(key));
210 | selectedObservable.unsubscribe();
211 | this.observerArray.delete(key);
212 | };
213 | return GentlemanStateService;
214 | }());
215 | GentlemanStateService.ɵfac = function GentlemanStateService_Factory(t) { return new (t || GentlemanStateService)(i0__namespace.ɵɵinject("sourceOfTruthKeys")); };
216 | GentlemanStateService.ɵprov = /*@__PURE__*/ i0__namespace.ɵɵdefineInjectable({ token: GentlemanStateService, factory: GentlemanStateService.ɵfac, providedIn: "root" });
217 | (function () {
218 | (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(GentlemanStateService, [{
219 | type: i0.Injectable,
220 | args: [{
221 | providedIn: "root",
222 | }]
223 | }], function () {
224 | return [{ type: undefined, decorators: [{
225 | type: i0.Inject,
226 | args: ["sourceOfTruthKeys"]
227 | }] }];
228 | }, null);
229 | })();
230 |
231 | var GentlemanStateManagerModule = /** @class */ (function () {
232 | function GentlemanStateManagerModule() {
233 | }
234 | GentlemanStateManagerModule.forRoot = function (sourceOfTruthKeys) {
235 | return {
236 | ngModule: GentlemanStateManagerModule,
237 | providers: [GentlemanStateService, { provide: 'sourceOfTruthKeys', useValue: sourceOfTruthKeys }]
238 | };
239 | };
240 | return GentlemanStateManagerModule;
241 | }());
242 | GentlemanStateManagerModule.ɵfac = function GentlemanStateManagerModule_Factory(t) { return new (t || GentlemanStateManagerModule)(); };
243 | GentlemanStateManagerModule.ɵmod = /*@__PURE__*/ i0__namespace.ɵɵdefineNgModule({ type: GentlemanStateManagerModule });
244 | GentlemanStateManagerModule.ɵinj = /*@__PURE__*/ i0__namespace.ɵɵdefineInjector({ imports: [[]] });
245 | (function () {
246 | (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(GentlemanStateManagerModule, [{
247 | type: i0.NgModule,
248 | args: [{
249 | declarations: [],
250 | imports: [],
251 | exports: []
252 | }]
253 | }], null, null);
254 | })();
255 |
256 | /*
257 | * Public API Surface of gentleman-state-manager
258 | */
259 |
260 | /**
261 | * Generated bundle index. Do not edit.
262 | */
263 |
264 | exports.GentlemanStateManagerModule = GentlemanStateManagerModule;
265 | exports.GentlemanStateObject = GentlemanStateObject;
266 | exports.GentlemanStateService = GentlemanStateService;
267 |
268 | Object.defineProperty(exports, '__esModule', { value: true });
269 |
270 | })));
271 | //# sourceMappingURL=gentleman-state-manager-lib.umd.js.map
272 |
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/bundles/gentleman-state-manager-lib.umd.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"gentleman-state-manager-lib.umd.js","sources":["../../../projects/gentleman-state-manager/src/lib/utils/functionalities.ts","../../../projects/gentleman-state-manager/src/lib/models/gentleman-state-object.ts","../../../projects/gentleman-state-manager/src/lib/services/gentleman-state.service.ts","../../../projects/gentleman-state-manager/src/lib/gentleman-state-manager.module.ts","../../../projects/gentleman-state-manager/src/public-api.ts","../../../projects/gentleman-state-manager/src/gentleman-state-manager-lib.ts"],"sourcesContent":["import {Condition} from '../models/utils';\r\n\r\n/**\r\n * @desc checks if the condition is met and returns its value\r\n * @param condition - the condition to check\r\n * @param errorMessage - the error message to be shown if the condition is not met\r\n * @return any\r\n */\r\n\r\nexport function checkIfConditionMet(condition: () => Condition, errorMessage: string): any {\r\n const conditionMet = condition();\r\n if (!conditionMet.met) {\r\n console.error(errorMessage);\r\n throw Error(errorMessage);\r\n }\r\n return conditionMet.value;\r\n}\r\n","import { BehaviorSubject, Observable } from 'rxjs';\r\nimport { map } from 'rxjs/operators';\r\nimport { checkIfConditionMet } from '../utils/public-api';\r\nimport { StateProperties, TypeWithKey } from './public-api';\r\n\r\nexport class GentlemanStateObject {\r\n private state: any;\r\n private stateProperties: StateProperties = {};\r\n readonly observableSubject: BehaviorSubject;\r\n\r\n constructor(state: any, stateProperties: StateProperties) {\r\n this.state = state;\r\n this.stateProperties = stateProperties;\r\n this.observableSubject = new BehaviorSubject(state);\r\n }\r\n\r\n /**\r\n * @desc returns the observable that contains the state for async operations - it listens for changes\r\n * @return Observable\r\n */\r\n getObservable(): Observable {\r\n return this.observableSubject.asObservable();\r\n }\r\n\r\n /**\r\n * @desc returns the state properties object\r\n * @return StateProperties\r\n */\r\n getStateProperties(): StateProperties {\r\n return this.stateProperties;\r\n }\r\n\r\n /**\r\n * @desc unsubscribes from the observable\r\n * @return void\r\n */\r\n unsubscribe(): void {\r\n this.observableSubject.unsubscribe();\r\n }\r\n\r\n /**\r\n * @desc returns the value of the state at the time of the call\r\n * @return any\r\n */\r\n getStateSnapshot(): any {\r\n return { ...this.state };\r\n }\r\n\r\n /**\r\n * @desc returns the value of a property of the state at the time of the call\r\n * @param property - the name of the requested property\r\n * @return any\r\n */\r\n getPropertyFromState(property: string): any {\r\n return this.state[property];\r\n }\r\n\r\n /**\r\n * @desc returns the value of a property of the state for async operations - it listens for changes\r\n * @param property - the name of the requested property\r\n * @return Observable\r\n */\r\n getPropertyFromObservable(property: string): Observable {\r\n return this.getObservable().pipe(map((s) => this.checkIfPropertyExists(s, property)));\r\n }\r\n\r\n /**\r\n * @desc sets the value for a certain property inside the state, triggers an async event\r\n * @param value - the value for the requested property\r\n * @param property - the name of the requested property\r\n * @param emit - if true it will trigger an async event\r\n * @return void\r\n */\r\n setObservableValues(value: any, property: string | null = null, emit = true): void {\r\n this.setStateValues(value, property);\r\n if (emit) {\r\n this.observableSubject.next(this.state);\r\n }\r\n }\r\n\r\n /**\r\n * @desc sets the value for a certain property inside the state, doesn't triggers an async event\r\n * @param value - the value for the requested property\r\n * @param property - the name of the requested property, if no property it will try to patch the values into the state\r\n * @return void\r\n */\r\n setStateValues(value: any, property: string | null): void {\r\n if (property && this.checkIfPropertyExists(this.state, property) !== undefined) {\r\n (this.state as TypeWithKey)[property] = value;\r\n } else {\r\n this.state = {\r\n ...this.state,\r\n ...value,\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * @desc resets the state\r\n * @return void\r\n */\r\n resetState(): void {\r\n (this.state as TypeWithKey) = {};\r\n }\r\n\r\n /**\r\n * @desc checks if the selected property exists inside the state\r\n * @param state - the state of the observable, the object that represents what the observable is going to contain\r\n * @param property - the selected property\r\n * @return any\r\n */\r\n private checkIfPropertyExists(state: any, property: string): any {\r\n const condition = () => {\r\n return { met: state.hasOwnProperty(property), value: state[property] };\r\n };\r\n return checkIfConditionMet(() => condition(), 'Selected property not found ! check if the key is correct and exists');\r\n }\r\n}\r\n","import { Inject, Injectable } from \"@angular/core\";\r\nimport { GentlemanStateObject, StateProperties } from \"../models/public-api\";\r\nimport { SourceOfTruth, SourceOfTruthInitiate } from \"../models/source-of-truth\";\r\nimport { checkIfConditionMet } from \"../utils/public-api\";\r\n\r\n@Injectable({\r\n providedIn: \"root\",\r\n})\r\nexport class GentlemanStateService {\r\n private observerArray: SourceOfTruth = new Map();\r\n\r\n constructor(@Inject(\"sourceOfTruthKeys\") sourceOfTruthKeys: SourceOfTruthInitiate[]) {\r\n sourceOfTruthKeys.forEach((k) => {\r\n const { state, stateProperties } = k;\r\n this.createObservable(k.key, state, stateProperties);\r\n });\r\n }\r\n\r\n /**\r\n * @desc it checks if the searched object exists, if not it throws an errors and stops the execution.\r\n * @param gentlemanObject - GentlemanStateObject | undefined\r\n * @return GentlemanStateObject\r\n */\r\n private static checkIfFound(gentlemanObject: GentlemanStateObject | undefined): GentlemanStateObject {\r\n const condition = () => {\r\n return { met: !!gentlemanObject, value: gentlemanObject };\r\n };\r\n return checkIfConditionMet(() => condition(), \"Observable item not found ! check if the key is correct and exists\");\r\n }\r\n\r\n /**\r\n * @desc it creates and observable and adds it to the observable array.\r\n * @param key - the key to be used to represent the observable item inside the array\r\n * @param state - the state of the observable, the object that represents what the observable is going to contain\r\n * @param stateProperties - the properties of the state\r\n * @return void\r\n */\r\n createObservable(key: string, state: any, stateProperties: StateProperties): void {\r\n const found = this.observerArray.has(key);\r\n if (found) {\r\n console.log(`the key : ${key}, already exists as an entity so it will be ignored`);\r\n } else {\r\n const gentlemanObject = new GentlemanStateObject(state, stateProperties);\r\n this.observerArray.set(key, gentlemanObject);\r\n }\r\n }\r\n\r\n /**\r\n * @desc it returns the selected observable using the provided key.\r\n * @param key - the key to be used to represent the observable item inside the array\r\n * @return GentlemanStateObject\r\n */\r\n getEntity(key: string): GentlemanStateObject {\r\n const observableArrayItem = GentlemanStateService.checkIfFound(this.observerArray.get(key));\r\n return observableArrayItem;\r\n }\r\n\r\n /**\r\n * @desc it emits a new value into the selected observable using the provided key.\r\n * @param key - the key to be used to represent the observable item inside the array\r\n * @param data - the data to be emitted inside the selected observable\r\n * @return void\r\n */\r\n emitValue(key: string, data: any): void {\r\n const observableArrayItem = GentlemanStateService.checkIfFound(this.observerArray.get(key));\r\n observableArrayItem.setObservableValues(data);\r\n }\r\n\r\n /**\r\n * @desc it destroys an object from the observable array.\r\n * @param key - the key to be used to represent the observable item inside the array\r\n * @return void\r\n */\r\n destroyObservable(key: string): void {\r\n const selectedObservable = GentlemanStateService.checkIfFound(this.observerArray.get(key));\r\n selectedObservable.unsubscribe();\r\n this.observerArray.delete(key);\r\n }\r\n}\r\n","import {ModuleWithProviders, NgModule} from '@angular/core';\r\nimport {SourceOfTruthInitiate} from './models/source-of-truth';\r\nimport {GentlemanStateService} from './services/public-api';\r\n\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [],\r\n exports: []\r\n})\r\nexport class GentlemanStateManagerModule {\r\n static forRoot(sourceOfTruthKeys: SourceOfTruthInitiate[]): ModuleWithProviders {\r\n return {\r\n ngModule: GentlemanStateManagerModule,\r\n providers: [GentlemanStateService, {provide: 'sourceOfTruthKeys', useValue: sourceOfTruthKeys}]\r\n };\r\n }\r\n}\r\n","/*\r\n * Public API Surface of gentleman-state-manager\r\n */\r\n\r\nexport * from './lib/public-api';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names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C,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3F,kBAAkB,CAAC,WAAW,EAAE,CAAC;YACjC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SAChC;;;8FArEU,qBAAqB,yBAGZ,mBAAmB;0FAH5B,qBAAqB,WAArB,qBAAqB,mBAFpB,MAAM;;2FAEP,qBAAqB;sBAHjCC,aAAU;uBAAC;wBACV,UAAU,EAAE,MAAM;qBACnB;;;kCAIcC,SAAM;mCAAC,mBAAmB;;;;;;QCDzC;;QACS,mCAAO,GAAd,UAAe,iBAA0C;YACvD,OAAO;gBACL,QAAQ,EAAE,2BAA2B;gBACrC,SAAS,EAAE,CAAC,qBAAqB,EAAE,EAAC,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,iBAAiB,EAAC,CAAC;aAChG,CAAC;SACH;;;0GANU,2BAA2B;4FAA3B,2BAA2B;gGAH7B,EAAE;;2FAGA,2BAA2B;sBALvCC,WAAQ;uBAAC;wBACR,YAAY,EAAE,EAAE;wBAChB,OAAO,EAAE,EAAE;wBACX,OAAO,EAAE,EAAE;qBACZ;;;;ICTD;;;;ICAA;;;;;;;;;;;;;;"}
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/esm2015/gentleman-state-manager-lib.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Generated bundle index. Do not edit.
3 | */
4 | export * from './public-api';
5 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VudGxlbWFuLXN0YXRlLW1hbmFnZXItbGliLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vcHJvamVjdHMvZ2VudGxlbWFuLXN0YXRlLW1hbmFnZXIvc3JjL2dlbnRsZW1hbi1zdGF0ZS1tYW5hZ2VyLWxpYi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpYy1hcGknO1xuIl19
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/esm2015/lib/gentleman-state-manager.module.js:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { GentlemanStateService } from './services/public-api';
3 | import * as i0 from "@angular/core";
4 | export class GentlemanStateManagerModule {
5 | static forRoot(sourceOfTruthKeys) {
6 | return {
7 | ngModule: GentlemanStateManagerModule,
8 | providers: [GentlemanStateService, { provide: 'sourceOfTruthKeys', useValue: sourceOfTruthKeys }]
9 | };
10 | }
11 | }
12 | GentlemanStateManagerModule.ɵfac = function GentlemanStateManagerModule_Factory(t) { return new (t || GentlemanStateManagerModule)(); };
13 | GentlemanStateManagerModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: GentlemanStateManagerModule });
14 | GentlemanStateManagerModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [[]] });
15 | (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GentlemanStateManagerModule, [{
16 | type: NgModule,
17 | args: [{
18 | declarations: [],
19 | imports: [],
20 | exports: []
21 | }]
22 | }], null, null); })();
23 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VudGxlbWFuLXN0YXRlLW1hbmFnZXIubW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvZ2VudGxlbWFuLXN0YXRlLW1hbmFnZXIvc3JjL2xpYi9nZW50bGVtYW4tc3RhdGUtbWFuYWdlci5tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBT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ogU291cmNlT2ZUcnV0aEluaXRpYXRlW10pOiBNb2R1bGVXaXRoUHJvdmlkZXJzPEdlbnRsZW1hblN0YXRlTWFuYWdlck1vZHVsZT4ge1xyXG4gICAgcmV0dXJuIHtcclxuICAgICAgbmdNb2R1bGU6IEdlbnRsZW1hblN0YXRlTWFuYWdlck1vZHVsZSxcclxuICAgICAgcHJvdmlkZXJzOiBbR2VudGxlbWFuU3RhdGVTZXJ2aWNlLCB7cHJvdmlkZTogJ3NvdXJjZU9mVHJ1dGhLZXlzJywgdXNlVmFsdWU6IHNvdXJjZU9mVHJ1dGhLZXlzfV1cclxuICAgIH07XHJcbiAgfVxyXG59XHJcbiJdfQ==
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/esm2015/lib/models/gentleman-state-object.js:
--------------------------------------------------------------------------------
1 | import { BehaviorSubject } from 'rxjs';
2 | import { map } from 'rxjs/operators';
3 | import { checkIfConditionMet } from '../utils/public-api';
4 | export class GentlemanStateObject {
5 | constructor(state, stateProperties) {
6 | this.stateProperties = {};
7 | this.state = state;
8 | this.stateProperties = stateProperties;
9 | this.observableSubject = new BehaviorSubject(state);
10 | }
11 | /**
12 | * @desc returns the observable that contains the state for async operations - it listens for changes
13 | * @return Observable
14 | */
15 | getObservable() {
16 | return this.observableSubject.asObservable();
17 | }
18 | /**
19 | * @desc returns the state properties object
20 | * @return StateProperties
21 | */
22 | getStateProperties() {
23 | return this.stateProperties;
24 | }
25 | /**
26 | * @desc unsubscribes from the observable
27 | * @return void
28 | */
29 | unsubscribe() {
30 | this.observableSubject.unsubscribe();
31 | }
32 | /**
33 | * @desc returns the value of the state at the time of the call
34 | * @return any
35 | */
36 | getStateSnapshot() {
37 | return Object.assign({}, this.state);
38 | }
39 | /**
40 | * @desc returns the value of a property of the state at the time of the call
41 | * @param property - the name of the requested property
42 | * @return any
43 | */
44 | getPropertyFromState(property) {
45 | return this.state[property];
46 | }
47 | /**
48 | * @desc returns the value of a property of the state for async operations - it listens for changes
49 | * @param property - the name of the requested property
50 | * @return Observable
51 | */
52 | getPropertyFromObservable(property) {
53 | return this.getObservable().pipe(map((s) => this.checkIfPropertyExists(s, property)));
54 | }
55 | /**
56 | * @desc sets the value for a certain property inside the state, triggers an async event
57 | * @param value - the value for the requested property
58 | * @param property - the name of the requested property
59 | * @param emit - if true it will trigger an async event
60 | * @return void
61 | */
62 | setObservableValues(value, property = null, emit = true) {
63 | this.setStateValues(value, property);
64 | if (emit) {
65 | this.observableSubject.next(this.state);
66 | }
67 | }
68 | /**
69 | * @desc sets the value for a certain property inside the state, doesn't triggers an async event
70 | * @param value - the value for the requested property
71 | * @param property - the name of the requested property, if no property it will try to patch the values into the state
72 | * @return void
73 | */
74 | setStateValues(value, property) {
75 | if (property && this.checkIfPropertyExists(this.state, property) !== undefined) {
76 | this.state[property] = value;
77 | }
78 | else {
79 | this.state = Object.assign(Object.assign({}, this.state), value);
80 | }
81 | }
82 | /**
83 | * @desc resets the state
84 | * @return void
85 | */
86 | resetState() {
87 | this.state = {};
88 | }
89 | /**
90 | * @desc checks if the selected property exists inside the state
91 | * @param state - the state of the observable, the object that represents what the observable is going to contain
92 | * @param property - the selected property
93 | * @return any
94 | */
95 | checkIfPropertyExists(state, property) {
96 | const condition = () => {
97 | return { met: state.hasOwnProperty(property), value: state[property] };
98 | };
99 | return checkIfConditionMet(() => condition(), 'Selected property not found ! check if the key is correct and exists');
100 | }
101 | }
102 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VudGxlbWFuLXN0YXRlLW9iamVjdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL2dlbnRsZW1hbi1zdGF0ZS1tYW5hZ2VyL3NyYy9saWIvbW9kZWxzL2dlbnRsZW1hbi1zdGF0ZS1vYmplY3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGVBQWUs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N0YXRlW3Byb3BlcnR5XSB9O1xyXG4gICAgfTtcclxuICAgIHJldHVybiBjaGVja0lmQ29uZGl0aW9uTWV0KCgpID0+IGNvbmRpdGlvbigpLCAnU2VsZWN0ZWQgcHJvcGVydHkgbm90IGZvdW5kICEgY2hlY2sgaWYgdGhlIGtleSBpcyBjb3JyZWN0IGFuZCBleGlzdHMnKTtcclxuICB9XHJcbn1cclxuIl19
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/esm2015/lib/models/public-api.js:
--------------------------------------------------------------------------------
1 | export * from './utils';
2 | export * from './state';
3 | export * from './gentleman-state-object';
4 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL2dlbnRsZW1hbi1zdGF0ZS1tYW5hZ2VyL3NyYy9saWIvbW9kZWxzL3B1YmxpYy1hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxTQUFTLENBQUM7QUFDeEIsY0FBYyxTQUFTLENBQUM7QUFDeEIsY0FBYywwQkFBMEIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gJy4vdXRpbHMnO1xyXG5leHBvcnQgKiBmcm9tICcuL3N0YXRlJztcclxuZXhwb3J0ICogZnJvbSAnLi9nZW50bGVtYW4tc3RhdGUtb2JqZWN0JztcclxuIl19
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/esm2015/lib/models/source-of-truth.js:
--------------------------------------------------------------------------------
1 | export {};
2 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic291cmNlLW9mLXRydXRoLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvZ2VudGxlbWFuLXN0YXRlLW1hbmFnZXIvc3JjL2xpYi9tb2RlbHMvc291cmNlLW9mLXRydXRoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBHZW50bGVtYW5TdGF0ZU9iamVjdCB9IGZyb20gXCIuLi9tb2RlbHMvcHVibGljLWFwaVwiO1xyXG5pbXBvcnQgeyBTdGF0ZVByb3BlcnRpZXMgfSBmcm9tIFwiLi9zdGF0ZVwiO1xyXG5cclxuZXhwb3J0IHR5cGUgU291cmNlT2ZUcnV0aCA9IE1hcDxzdHJpbmcsIEdlbnRsZW1hblN0YXRlT2JqZWN0PjtcclxuXHJcbmV4cG9ydCBpbnRlcmZhY2UgU291cmNlT2ZUcnV0aEluaXRpYXRlIHtcclxuICBrZXk6IHN0cmluZztcclxuICBzdGF0ZTogYW55O1xyXG4gIHN0YXRlUHJvcGVydGllczogU3RhdGVQcm9wZXJ0aWVzO1xyXG59XHJcbiJdfQ==
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/esm2015/lib/models/state.js:
--------------------------------------------------------------------------------
1 | export {};
2 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhdGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9nZW50bGVtYW4tc3RhdGUtbWFuYWdlci9zcmMvbGliL21vZGVscy9zdGF0ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGludGVyZmFjZSBTdGF0ZVByb3BlcnRpZXMge1xyXG4gIFtrZXk6IHN0cmluZ106IHN0cmluZztcclxufVxyXG4iXX0=
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/esm2015/lib/models/utils.js:
--------------------------------------------------------------------------------
1 | export {};
2 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9nZW50bGVtYW4tc3RhdGUtbWFuYWdlci9zcmMvbGliL21vZGVscy91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHR5cGUgVHlwZVdpdGhLZXk8VD4gPSB7IFtrZXk6IHN0cmluZ106IFQgfTtcclxuXHJcbmV4cG9ydCBpbnRlcmZhY2UgQ29uZGl0aW9uIHtcclxuICAgIG1ldDogYm9vbGVhbjtcclxuICAgIHZhbHVlOiBhbnk7XHJcbn1cclxuIl19
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/esm2015/lib/public-api.js:
--------------------------------------------------------------------------------
1 | export * from './services/public-api';
2 | export * from './models/public-api';
3 | export * from './gentleman-state-manager.module';
4 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL2dlbnRsZW1hbi1zdGF0ZS1tYW5hZ2VyL3NyYy9saWIvcHVibGljLWFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHVCQUF1QixDQUFDO0FBQ3RDLGNBQWMscUJBQXFCLENBQUM7QUFDcEMsY0FBYyxrQ0FBa0MsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gJy4vc2VydmljZXMvcHVibGljLWFwaSc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbW9kZWxzL3B1YmxpYy1hcGknO1xyXG5leHBvcnQgKiBmcm9tICcuL2dlbnRsZW1hbi1zdGF0ZS1tYW5hZ2VyLm1vZHVsZSc7XHJcbiJdfQ==
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/esm2015/lib/services/gentleman-state.service.js:
--------------------------------------------------------------------------------
1 | import { Inject, Injectable } from "@angular/core";
2 | import { GentlemanStateObject } from "../models/public-api";
3 | import { checkIfConditionMet } from "../utils/public-api";
4 | import * as i0 from "@angular/core";
5 | export class GentlemanStateService {
6 | constructor(sourceOfTruthKeys) {
7 | this.observerArray = new Map();
8 | sourceOfTruthKeys.forEach((k) => {
9 | const { state, stateProperties } = k;
10 | this.createObservable(k.key, state, stateProperties);
11 | });
12 | }
13 | /**
14 | * @desc it checks if the searched object exists, if not it throws an errors and stops the execution.
15 | * @param gentlemanObject - GentlemanStateObject | undefined
16 | * @return GentlemanStateObject
17 | */
18 | static checkIfFound(gentlemanObject) {
19 | const condition = () => {
20 | return { met: !!gentlemanObject, value: gentlemanObject };
21 | };
22 | return checkIfConditionMet(() => condition(), "Observable item not found ! check if the key is correct and exists");
23 | }
24 | /**
25 | * @desc it creates and observable and adds it to the observable array.
26 | * @param key - the key to be used to represent the observable item inside the array
27 | * @param state - the state of the observable, the object that represents what the observable is going to contain
28 | * @param stateProperties - the properties of the state
29 | * @return void
30 | */
31 | createObservable(key, state, stateProperties) {
32 | const found = this.observerArray.has(key);
33 | if (found) {
34 | console.log(`the key : ${key}, already exists as an entity so it will be ignored`);
35 | }
36 | else {
37 | const gentlemanObject = new GentlemanStateObject(state, stateProperties);
38 | this.observerArray.set(key, gentlemanObject);
39 | }
40 | }
41 | /**
42 | * @desc it returns the selected observable using the provided key.
43 | * @param key - the key to be used to represent the observable item inside the array
44 | * @return GentlemanStateObject
45 | */
46 | getEntity(key) {
47 | const observableArrayItem = GentlemanStateService.checkIfFound(this.observerArray.get(key));
48 | return observableArrayItem;
49 | }
50 | /**
51 | * @desc it emits a new value into the selected observable using the provided key.
52 | * @param key - the key to be used to represent the observable item inside the array
53 | * @param data - the data to be emitted inside the selected observable
54 | * @return void
55 | */
56 | emitValue(key, data) {
57 | const observableArrayItem = GentlemanStateService.checkIfFound(this.observerArray.get(key));
58 | observableArrayItem.setObservableValues(data);
59 | }
60 | /**
61 | * @desc it destroys an object from the observable array.
62 | * @param key - the key to be used to represent the observable item inside the array
63 | * @return void
64 | */
65 | destroyObservable(key) {
66 | const selectedObservable = GentlemanStateService.checkIfFound(this.observerArray.get(key));
67 | selectedObservable.unsubscribe();
68 | this.observerArray.delete(key);
69 | }
70 | }
71 | GentlemanStateService.ɵfac = function GentlemanStateService_Factory(t) { return new (t || GentlemanStateService)(i0.ɵɵinject("sourceOfTruthKeys")); };
72 | GentlemanStateService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: GentlemanStateService, factory: GentlemanStateService.ɵfac, providedIn: "root" });
73 | (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GentlemanStateService, [{
74 | type: Injectable,
75 | args: [{
76 | providedIn: "root",
77 | }]
78 | }], function () { return [{ type: undefined, decorators: [{
79 | type: Inject,
80 | args: ["sourceOfTruthKeys"]
81 | }] }]; }, null); })();
82 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VudGxlbWFuLXN0YXRlLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9nZW50bGVtYW4tc3RhdGUtbWFuYWdlci9zcmMvbGliL3NlcnZpY2VzL2dlbnRsZW1hbi1zdGF0ZS5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxNQUFNLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ25ELE9BQU8sRUFBRSxvQkFBb0IsRUFBbUIsTUFBTSxzQkFBc0IsQ0FBQztBQUU3RSxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQzs7QUFLMUQsTUFBTSxPQUFPLHFCQUFxQjtJQUdoQyxZQUF5QyxpQk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9cclxuICBkZXN0cm95T2JzZXJ2YWJsZShrZXk6IHN0cmluZyk6IHZvaWQge1xyXG4gICAgY29uc3Qgc2VsZWN0ZWRPYnNlcnZhYmxlID0gR2VudGxlbWFuU3RhdGVTZXJ2aWNlLmNoZWNrSWZGb3VuZCh0aGlzLm9ic2VydmVyQXJyYXkuZ2V0KGtleSkpO1xyXG4gICAgc2VsZWN0ZWRPYnNlcnZhYmxlLnVuc3Vic2NyaWJlKCk7XHJcbiAgICB0aGlzLm9ic2VydmVyQXJyYXkuZGVsZXRlKGtleSk7XHJcbiAgfVxyXG59XHJcbiJdfQ==
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/esm2015/lib/services/public-api.js:
--------------------------------------------------------------------------------
1 | export * from './gentleman-state.service';
2 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL2dlbnRsZW1hbi1zdGF0ZS1tYW5hZ2VyL3NyYy9saWIvc2VydmljZXMvcHVibGljLWFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDJCQUEyQixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9nZW50bGVtYW4tc3RhdGUuc2VydmljZSc7XHJcbiJdfQ==
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/esm2015/lib/utils/functionalities.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @desc checks if the condition is met and returns its value
3 | * @param condition - the condition to check
4 | * @param errorMessage - the error message to be shown if the condition is not met
5 | * @return any
6 | */
7 | export function checkIfConditionMet(condition, errorMessage) {
8 | const conditionMet = condition();
9 | if (!conditionMet.met) {
10 | console.error(errorMessage);
11 | throw Error(errorMessage);
12 | }
13 | return conditionMet.value;
14 | }
15 | //# sourceMappingURL=data:application/json;base64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3JNZXNzYWdlOiBzdHJpbmcpOiBhbnkge1xyXG4gIGNvbnN0IGNvbmRpdGlvbk1ldCA9IGNvbmRpdGlvbigpO1xyXG4gIGlmICghY29uZGl0aW9uTWV0Lm1ldCkge1xyXG4gICAgY29uc29sZS5lcnJvcihlcnJvck1lc3NhZ2UpO1xyXG4gICAgdGhyb3cgRXJyb3IoZXJyb3JNZXNzYWdlKTtcclxuICB9XHJcbiAgcmV0dXJuIGNvbmRpdGlvbk1ldC52YWx1ZTtcclxufVxyXG4iXX0=
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/esm2015/lib/utils/public-api.js:
--------------------------------------------------------------------------------
1 | export * from './functionalities';
2 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL2dlbnRsZW1hbi1zdGF0ZS1tYW5hZ2VyL3NyYy9saWIvdXRpbHMvcHVibGljLWFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLG1CQUFtQixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9mdW5jdGlvbmFsaXRpZXMnO1xyXG4iXX0=
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/esm2015/public-api.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Public API Surface of gentleman-state-manager
3 | */
4 | export * from './lib/public-api';
5 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL2dlbnRsZW1hbi1zdGF0ZS1tYW5hZ2VyL3NyYy9wdWJsaWMtYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsY0FBYyxrQkFBa0IsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXHJcbiAqIFB1YmxpYyBBUEkgU3VyZmFjZSBvZiBnZW50bGVtYW4tc3RhdGUtbWFuYWdlclxyXG4gKi9cclxuXHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL3B1YmxpYy1hcGknO1xyXG4iXX0=
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/fesm2015/gentleman-state-manager-lib.js:
--------------------------------------------------------------------------------
1 | import * as i0 from '@angular/core';
2 | import { Injectable, Inject, NgModule } from '@angular/core';
3 | import { BehaviorSubject } from 'rxjs';
4 | import { map } from 'rxjs/operators';
5 |
6 | /**
7 | * @desc checks if the condition is met and returns its value
8 | * @param condition - the condition to check
9 | * @param errorMessage - the error message to be shown if the condition is not met
10 | * @return any
11 | */
12 | function checkIfConditionMet(condition, errorMessage) {
13 | const conditionMet = condition();
14 | if (!conditionMet.met) {
15 | console.error(errorMessage);
16 | throw Error(errorMessage);
17 | }
18 | return conditionMet.value;
19 | }
20 |
21 | class GentlemanStateObject {
22 | constructor(state, stateProperties) {
23 | this.stateProperties = {};
24 | this.state = state;
25 | this.stateProperties = stateProperties;
26 | this.observableSubject = new BehaviorSubject(state);
27 | }
28 | /**
29 | * @desc returns the observable that contains the state for async operations - it listens for changes
30 | * @return Observable
31 | */
32 | getObservable() {
33 | return this.observableSubject.asObservable();
34 | }
35 | /**
36 | * @desc returns the state properties object
37 | * @return StateProperties
38 | */
39 | getStateProperties() {
40 | return this.stateProperties;
41 | }
42 | /**
43 | * @desc unsubscribes from the observable
44 | * @return void
45 | */
46 | unsubscribe() {
47 | this.observableSubject.unsubscribe();
48 | }
49 | /**
50 | * @desc returns the value of the state at the time of the call
51 | * @return any
52 | */
53 | getStateSnapshot() {
54 | return Object.assign({}, this.state);
55 | }
56 | /**
57 | * @desc returns the value of a property of the state at the time of the call
58 | * @param property - the name of the requested property
59 | * @return any
60 | */
61 | getPropertyFromState(property) {
62 | return this.state[property];
63 | }
64 | /**
65 | * @desc returns the value of a property of the state for async operations - it listens for changes
66 | * @param property - the name of the requested property
67 | * @return Observable
68 | */
69 | getPropertyFromObservable(property) {
70 | return this.getObservable().pipe(map((s) => this.checkIfPropertyExists(s, property)));
71 | }
72 | /**
73 | * @desc sets the value for a certain property inside the state, triggers an async event
74 | * @param value - the value for the requested property
75 | * @param property - the name of the requested property
76 | * @param emit - if true it will trigger an async event
77 | * @return void
78 | */
79 | setObservableValues(value, property = null, emit = true) {
80 | this.setStateValues(value, property);
81 | if (emit) {
82 | this.observableSubject.next(this.state);
83 | }
84 | }
85 | /**
86 | * @desc sets the value for a certain property inside the state, doesn't triggers an async event
87 | * @param value - the value for the requested property
88 | * @param property - the name of the requested property, if no property it will try to patch the values into the state
89 | * @return void
90 | */
91 | setStateValues(value, property) {
92 | if (property && this.checkIfPropertyExists(this.state, property) !== undefined) {
93 | this.state[property] = value;
94 | }
95 | else {
96 | this.state = Object.assign(Object.assign({}, this.state), value);
97 | }
98 | }
99 | /**
100 | * @desc resets the state
101 | * @return void
102 | */
103 | resetState() {
104 | this.state = {};
105 | }
106 | /**
107 | * @desc checks if the selected property exists inside the state
108 | * @param state - the state of the observable, the object that represents what the observable is going to contain
109 | * @param property - the selected property
110 | * @return any
111 | */
112 | checkIfPropertyExists(state, property) {
113 | const condition = () => {
114 | return { met: state.hasOwnProperty(property), value: state[property] };
115 | };
116 | return checkIfConditionMet(() => condition(), 'Selected property not found ! check if the key is correct and exists');
117 | }
118 | }
119 |
120 | class GentlemanStateService {
121 | constructor(sourceOfTruthKeys) {
122 | this.observerArray = new Map();
123 | sourceOfTruthKeys.forEach((k) => {
124 | const { state, stateProperties } = k;
125 | this.createObservable(k.key, state, stateProperties);
126 | });
127 | }
128 | /**
129 | * @desc it checks if the searched object exists, if not it throws an errors and stops the execution.
130 | * @param gentlemanObject - GentlemanStateObject | undefined
131 | * @return GentlemanStateObject
132 | */
133 | static checkIfFound(gentlemanObject) {
134 | const condition = () => {
135 | return { met: !!gentlemanObject, value: gentlemanObject };
136 | };
137 | return checkIfConditionMet(() => condition(), "Observable item not found ! check if the key is correct and exists");
138 | }
139 | /**
140 | * @desc it creates and observable and adds it to the observable array.
141 | * @param key - the key to be used to represent the observable item inside the array
142 | * @param state - the state of the observable, the object that represents what the observable is going to contain
143 | * @param stateProperties - the properties of the state
144 | * @return void
145 | */
146 | createObservable(key, state, stateProperties) {
147 | const found = this.observerArray.has(key);
148 | if (found) {
149 | console.log(`the key : ${key}, already exists as an entity so it will be ignored`);
150 | }
151 | else {
152 | const gentlemanObject = new GentlemanStateObject(state, stateProperties);
153 | this.observerArray.set(key, gentlemanObject);
154 | }
155 | }
156 | /**
157 | * @desc it returns the selected observable using the provided key.
158 | * @param key - the key to be used to represent the observable item inside the array
159 | * @return GentlemanStateObject
160 | */
161 | getEntity(key) {
162 | const observableArrayItem = GentlemanStateService.checkIfFound(this.observerArray.get(key));
163 | return observableArrayItem;
164 | }
165 | /**
166 | * @desc it emits a new value into the selected observable using the provided key.
167 | * @param key - the key to be used to represent the observable item inside the array
168 | * @param data - the data to be emitted inside the selected observable
169 | * @return void
170 | */
171 | emitValue(key, data) {
172 | const observableArrayItem = GentlemanStateService.checkIfFound(this.observerArray.get(key));
173 | observableArrayItem.setObservableValues(data);
174 | }
175 | /**
176 | * @desc it destroys an object from the observable array.
177 | * @param key - the key to be used to represent the observable item inside the array
178 | * @return void
179 | */
180 | destroyObservable(key) {
181 | const selectedObservable = GentlemanStateService.checkIfFound(this.observerArray.get(key));
182 | selectedObservable.unsubscribe();
183 | this.observerArray.delete(key);
184 | }
185 | }
186 | GentlemanStateService.ɵfac = function GentlemanStateService_Factory(t) { return new (t || GentlemanStateService)(i0.ɵɵinject("sourceOfTruthKeys")); };
187 | GentlemanStateService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: GentlemanStateService, factory: GentlemanStateService.ɵfac, providedIn: "root" });
188 | (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GentlemanStateService, [{
189 | type: Injectable,
190 | args: [{
191 | providedIn: "root",
192 | }]
193 | }], function () { return [{ type: undefined, decorators: [{
194 | type: Inject,
195 | args: ["sourceOfTruthKeys"]
196 | }] }]; }, null); })();
197 |
198 | class GentlemanStateManagerModule {
199 | static forRoot(sourceOfTruthKeys) {
200 | return {
201 | ngModule: GentlemanStateManagerModule,
202 | providers: [GentlemanStateService, { provide: 'sourceOfTruthKeys', useValue: sourceOfTruthKeys }]
203 | };
204 | }
205 | }
206 | GentlemanStateManagerModule.ɵfac = function GentlemanStateManagerModule_Factory(t) { return new (t || GentlemanStateManagerModule)(); };
207 | GentlemanStateManagerModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: GentlemanStateManagerModule });
208 | GentlemanStateManagerModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [[]] });
209 | (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GentlemanStateManagerModule, [{
210 | type: NgModule,
211 | args: [{
212 | declarations: [],
213 | imports: [],
214 | exports: []
215 | }]
216 | }], null, null); })();
217 |
218 | /*
219 | * Public API Surface of gentleman-state-manager
220 | */
221 |
222 | /**
223 | * Generated bundle index. Do not edit.
224 | */
225 |
226 | export { GentlemanStateManagerModule, GentlemanStateObject, GentlemanStateService };
227 | //# sourceMappingURL=gentleman-state-manager-lib.js.map
228 |
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/fesm2015/gentleman-state-manager-lib.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"gentleman-state-manager-lib.js","sources":["../../../projects/gentleman-state-manager/src/lib/utils/functionalities.ts","../../../projects/gentleman-state-manager/src/lib/models/gentleman-state-object.ts","../../../projects/gentleman-state-manager/src/lib/services/gentleman-state.service.ts","../../../projects/gentleman-state-manager/src/lib/gentleman-state-manager.module.ts","../../../projects/gentleman-state-manager/src/public-api.ts","../../../projects/gentleman-state-manager/src/gentleman-state-manager-lib.ts"],"sourcesContent":["import {Condition} from '../models/utils';\r\n\r\n/**\r\n * @desc checks if the condition is met and returns its value\r\n * @param condition - the condition to check\r\n * @param errorMessage - the error message to be shown if the condition is not met\r\n * @return any\r\n */\r\n\r\nexport function checkIfConditionMet(condition: () => Condition, errorMessage: string): any {\r\n const conditionMet = condition();\r\n if (!conditionMet.met) {\r\n console.error(errorMessage);\r\n throw Error(errorMessage);\r\n }\r\n return conditionMet.value;\r\n}\r\n","import { BehaviorSubject, Observable } from 'rxjs';\r\nimport { map } from 'rxjs/operators';\r\nimport { checkIfConditionMet } from '../utils/public-api';\r\nimport { StateProperties, TypeWithKey } from './public-api';\r\n\r\nexport class GentlemanStateObject {\r\n private state: any;\r\n private stateProperties: StateProperties = {};\r\n readonly observableSubject: BehaviorSubject;\r\n\r\n constructor(state: any, stateProperties: StateProperties) {\r\n this.state = state;\r\n this.stateProperties = stateProperties;\r\n this.observableSubject = new BehaviorSubject(state);\r\n }\r\n\r\n /**\r\n * @desc returns the observable that contains the state for async operations - it listens for changes\r\n * @return Observable\r\n */\r\n getObservable(): Observable {\r\n return this.observableSubject.asObservable();\r\n }\r\n\r\n /**\r\n * @desc returns the state properties object\r\n * @return StateProperties\r\n */\r\n getStateProperties(): StateProperties {\r\n return this.stateProperties;\r\n }\r\n\r\n /**\r\n * @desc unsubscribes from the observable\r\n * @return void\r\n */\r\n unsubscribe(): void {\r\n this.observableSubject.unsubscribe();\r\n }\r\n\r\n /**\r\n * @desc returns the value of the state at the time of the call\r\n * @return any\r\n */\r\n getStateSnapshot(): any {\r\n return { ...this.state };\r\n }\r\n\r\n /**\r\n * @desc returns the value of a property of the state at the time of the call\r\n * @param property - the name of the requested property\r\n * @return any\r\n */\r\n getPropertyFromState(property: string): any {\r\n return this.state[property];\r\n }\r\n\r\n /**\r\n * @desc returns the value of a property of the state for async operations - it listens for changes\r\n * @param property - the name of the requested property\r\n * @return Observable\r\n */\r\n getPropertyFromObservable(property: string): Observable {\r\n return this.getObservable().pipe(map((s) => this.checkIfPropertyExists(s, property)));\r\n }\r\n\r\n /**\r\n * @desc sets the value for a certain property inside the state, triggers an async event\r\n * @param value - the value for the requested property\r\n * @param property - the name of the requested property\r\n * @param emit - if true it will trigger an async event\r\n * @return void\r\n */\r\n setObservableValues(value: any, property: string | null = null, emit = true): void {\r\n this.setStateValues(value, property);\r\n if (emit) {\r\n this.observableSubject.next(this.state);\r\n }\r\n }\r\n\r\n /**\r\n * @desc sets the value for a certain property inside the state, doesn't triggers an async event\r\n * @param value - the value for the requested property\r\n * @param property - the name of the requested property, if no property it will try to patch the values into the state\r\n * @return void\r\n */\r\n setStateValues(value: any, property: string | null): void {\r\n if (property && this.checkIfPropertyExists(this.state, property) !== undefined) {\r\n (this.state as TypeWithKey)[property] = value;\r\n } else {\r\n this.state = {\r\n ...this.state,\r\n ...value,\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * @desc resets the state\r\n * @return void\r\n */\r\n resetState(): void {\r\n (this.state as TypeWithKey) = {};\r\n }\r\n\r\n /**\r\n * @desc checks if the selected property exists inside the state\r\n * @param state - the state of the observable, the object that represents what the observable is going to contain\r\n * @param property - the selected property\r\n * @return any\r\n */\r\n private checkIfPropertyExists(state: any, property: string): any {\r\n const condition = () => {\r\n return { met: state.hasOwnProperty(property), value: state[property] };\r\n };\r\n return checkIfConditionMet(() => condition(), 'Selected property not found ! check if the key is correct and exists');\r\n }\r\n}\r\n","import { Inject, Injectable } from \"@angular/core\";\r\nimport { GentlemanStateObject, StateProperties } from \"../models/public-api\";\r\nimport { SourceOfTruth, SourceOfTruthInitiate } from \"../models/source-of-truth\";\r\nimport { checkIfConditionMet } from \"../utils/public-api\";\r\n\r\n@Injectable({\r\n providedIn: \"root\",\r\n})\r\nexport class GentlemanStateService {\r\n private observerArray: SourceOfTruth = new Map();\r\n\r\n constructor(@Inject(\"sourceOfTruthKeys\") sourceOfTruthKeys: SourceOfTruthInitiate[]) {\r\n sourceOfTruthKeys.forEach((k) => {\r\n const { state, stateProperties } = k;\r\n this.createObservable(k.key, state, stateProperties);\r\n });\r\n }\r\n\r\n /**\r\n * @desc it checks if the searched object exists, if not it throws an errors and stops the execution.\r\n * @param gentlemanObject - GentlemanStateObject | undefined\r\n * @return GentlemanStateObject\r\n */\r\n private static checkIfFound(gentlemanObject: GentlemanStateObject | undefined): GentlemanStateObject {\r\n const condition = () => {\r\n return { met: !!gentlemanObject, value: gentlemanObject };\r\n };\r\n return checkIfConditionMet(() => condition(), \"Observable item not found ! check if the key is correct and exists\");\r\n }\r\n\r\n /**\r\n * @desc it creates and observable and adds it to the observable array.\r\n * @param key - the key to be used to represent the observable item inside the array\r\n * @param state - the state of the observable, the object that represents what the observable is going to contain\r\n * @param stateProperties - the properties of the state\r\n * @return void\r\n */\r\n createObservable(key: string, state: any, stateProperties: StateProperties): void {\r\n const found = this.observerArray.has(key);\r\n if (found) {\r\n console.log(`the key : ${key}, already exists as an entity so it will be ignored`);\r\n } else {\r\n const gentlemanObject = new GentlemanStateObject(state, stateProperties);\r\n this.observerArray.set(key, gentlemanObject);\r\n }\r\n }\r\n\r\n /**\r\n * @desc it returns the selected observable using the provided key.\r\n * @param key - the key to be used to represent the observable item inside the array\r\n * @return GentlemanStateObject\r\n */\r\n getEntity(key: string): GentlemanStateObject {\r\n const observableArrayItem = GentlemanStateService.checkIfFound(this.observerArray.get(key));\r\n return observableArrayItem;\r\n }\r\n\r\n /**\r\n * @desc it emits a new value into the selected observable using the provided key.\r\n * @param key - the key to be used to represent the observable item inside the array\r\n * @param data - the data to be emitted inside the selected observable\r\n * @return void\r\n */\r\n emitValue(key: string, data: any): void {\r\n const observableArrayItem = GentlemanStateService.checkIfFound(this.observerArray.get(key));\r\n observableArrayItem.setObservableValues(data);\r\n }\r\n\r\n /**\r\n * @desc it destroys an object from the observable array.\r\n * @param key - the key to be used to represent the observable item inside the array\r\n * @return void\r\n */\r\n destroyObservable(key: string): void {\r\n const selectedObservable = GentlemanStateService.checkIfFound(this.observerArray.get(key));\r\n selectedObservable.unsubscribe();\r\n this.observerArray.delete(key);\r\n }\r\n}\r\n","import {ModuleWithProviders, NgModule} from '@angular/core';\r\nimport {SourceOfTruthInitiate} from './models/source-of-truth';\r\nimport {GentlemanStateService} from './services/public-api';\r\n\r\n\r\n@NgModule({\r\n declarations: [],\r\n imports: [],\r\n exports: []\r\n})\r\nexport class GentlemanStateManagerModule {\r\n static forRoot(sourceOfTruthKeys: SourceOfTruthInitiate[]): ModuleWithProviders {\r\n return {\r\n ngModule: GentlemanStateManagerModule,\r\n providers: [GentlemanStateService, {provide: 'sourceOfTruthKeys', useValue: sourceOfTruthKeys}]\r\n };\r\n }\r\n}\r\n","/*\r\n * Public API Surface of gentleman-state-manager\r\n */\r\n\r\nexport * from './lib/public-api';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAEA;;;;;;SAOgB,mBAAmB,CAAC,SAA0B,EAAE,YAAoB;IAClF,MAAM,YAAY,GAAG,SAAS,EAAE,CAAC;IACjC,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE;QACrB,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC5B,MAAM,KAAK,CAAC,YAAY,CAAC,CAAC;KAC3B;IACD,OAAO,YAAY,CAAC,KAAK,CAAC;AAC5B;;MCXa,oBAAoB;IAK/B,YAAY,KAAU,EAAE,eAAgC;QAHhD,oBAAe,GAAoB,EAAE,CAAC;QAI5C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,iBAAiB,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;KACrD;;;;;IAMD,aAAa;QACX,OAAO,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE,CAAC;KAC9C;;;;;IAMD,kBAAkB;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;KAC7B;;;;;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AE,IAAS;QAC9B,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5F,mBAAmB,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;KAC/C;;;;;;IAOD,iBAAiB,CAAC,GAAW;QAC3B,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3F,kBAAkB,CAAC,WAAW,EAAE,CAAC;QACjC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KAChC;;0FArEU,qBAAqB,cAGZ,mBAAmB;2EAH5B,qBAAqB,WAArB,qBAAqB,mBAFpB,MAAM;uFAEP,qBAAqB;cAHjC,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB;;sBAIc,MAAM;uBAAC,mBAAmB;;;MCD5B,2BAA2B;IACtC,OAAO,OAAO,CAAC,iBAA0C;QACvD,OAAO;YACL,QAAQ,EAAE,2BAA2B;YACrC,SAAS,EAAE,CAAC,qBAAqB,EAAE,EAAC,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,iBAAiB,EAAC,CAAC;SAChG,CAAC;KACH;;sGANU,2BAA2B;6EAA3B,2BAA2B;iFAH7B,EAAE;uFAGA,2BAA2B;cALvC,QAAQ;eAAC;gBACR,YAAY,EAAE,EAAE;gBAChB,OAAO,EAAE,EAAE;gBACX,OAAO,EAAE,EAAE;aACZ;;;ACTD;;;;ACAA;;;;;;"}
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/gentleman-state-manager-lib.d.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Generated bundle index. Do not edit.
3 | */
4 | ///
5 | export * from './public-api';
6 | //# sourceMappingURL=gentleman-state-manager-lib.d.ts.map
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/gentleman-state-manager-lib.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"gentleman-state-manager-lib.d.ts","sourceRoot":"","sources":["../../projects/gentleman-state-manager/src/gentleman-state-manager-lib.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,cAAc,cAAc,CAAC"}
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/gentleman-state-manager.module.d.ts:
--------------------------------------------------------------------------------
1 | import { ModuleWithProviders } from '@angular/core';
2 | import { SourceOfTruthInitiate } from './models/source-of-truth';
3 | import * as i0 from "@angular/core";
4 | export declare class GentlemanStateManagerModule {
5 | static forRoot(sourceOfTruthKeys: SourceOfTruthInitiate[]): ModuleWithProviders;
6 | static ɵfac: i0.ɵɵFactoryDeclaration;
7 | static ɵmod: i0.ɵɵNgModuleDeclaration;
8 | static ɵinj: i0.ɵɵInjectorDeclaration;
9 | }
10 | //# sourceMappingURL=gentleman-state-manager.module.d.ts.map
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/gentleman-state-manager.module.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"gentleman-state-manager.module.d.ts","sourceRoot":"","sources":["../../../projects/gentleman-state-manager/src/lib/gentleman-state-manager.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAW,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAC,qBAAqB,EAAC,MAAM,0BAA0B,CAAC;;AAI/D,qBAKa,2BAA2B;IACtC,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,qBAAqB,EAAE,GAAG,mBAAmB,CAAC,2BAA2B,CAAC;yCADjG,2BAA2B;0CAA3B,2BAA2B;0CAA3B,2BAA2B;CAOvC"}
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/models/gentleman-state-object.d.ts:
--------------------------------------------------------------------------------
1 | import { BehaviorSubject, Observable } from 'rxjs';
2 | import { StateProperties } from './public-api';
3 | export declare class GentlemanStateObject {
4 | private state;
5 | private stateProperties;
6 | readonly observableSubject: BehaviorSubject;
7 | constructor(state: any, stateProperties: StateProperties);
8 | /**
9 | * @desc returns the observable that contains the state for async operations - it listens for changes
10 | * @return Observable
11 | */
12 | getObservable(): Observable;
13 | /**
14 | * @desc returns the state properties object
15 | * @return StateProperties
16 | */
17 | getStateProperties(): StateProperties;
18 | /**
19 | * @desc unsubscribes from the observable
20 | * @return void
21 | */
22 | unsubscribe(): void;
23 | /**
24 | * @desc returns the value of the state at the time of the call
25 | * @return any
26 | */
27 | getStateSnapshot(): any;
28 | /**
29 | * @desc returns the value of a property of the state at the time of the call
30 | * @param property - the name of the requested property
31 | * @return any
32 | */
33 | getPropertyFromState(property: string): any;
34 | /**
35 | * @desc returns the value of a property of the state for async operations - it listens for changes
36 | * @param property - the name of the requested property
37 | * @return Observable
38 | */
39 | getPropertyFromObservable(property: string): Observable;
40 | /**
41 | * @desc sets the value for a certain property inside the state, triggers an async event
42 | * @param value - the value for the requested property
43 | * @param property - the name of the requested property
44 | * @param emit - if true it will trigger an async event
45 | * @return void
46 | */
47 | setObservableValues(value: any, property?: string | null, emit?: boolean): void;
48 | /**
49 | * @desc sets the value for a certain property inside the state, doesn't triggers an async event
50 | * @param value - the value for the requested property
51 | * @param property - the name of the requested property, if no property it will try to patch the values into the state
52 | * @return void
53 | */
54 | setStateValues(value: any, property: string | null): void;
55 | /**
56 | * @desc resets the state
57 | * @return void
58 | */
59 | resetState(): void;
60 | /**
61 | * @desc checks if the selected property exists inside the state
62 | * @param state - the state of the observable, the object that represents what the observable is going to contain
63 | * @param property - the selected property
64 | * @return any
65 | */
66 | private checkIfPropertyExists;
67 | }
68 | //# sourceMappingURL=gentleman-state-object.d.ts.map
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/models/gentleman-state-object.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"gentleman-state-object.d.ts","sourceRoot":"","sources":["../../../../projects/gentleman-state-manager/src/lib/models/gentleman-state-object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGnD,OAAO,EAAE,eAAe,EAAe,MAAM,cAAc,CAAC;AAE5D,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,eAAe,CAAuB;IAC9C,QAAQ,CAAC,iBAAiB,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;gBAErC,KAAK,EAAE,GAAG,EAAE,eAAe,EAAE,eAAe;IAMxD;;;OAGG;IACH,aAAa,IAAI,UAAU,CAAC,GAAG,CAAC;IAIhC;;;OAGG;IACH,kBAAkB,IAAI,eAAe;IAIrC;;;OAGG;IACH,WAAW,IAAI,IAAI;IAInB;;;OAGG;IACH,gBAAgB,IAAI,GAAG;IAIvB;;;;OAIG;IACH,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG;IAI3C;;;;OAIG;IACH,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC;IAI5D;;;;;;OAMG;IACH,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,GAAE,MAAM,GAAG,IAAW,EAAE,IAAI,UAAO,GAAG,IAAI;IAOlF;;;;;OAKG;IACH,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAWzD;;;OAGG;IACH,UAAU,IAAI,IAAI;IAIlB;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;CAM9B"}
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/models/public-api.d.ts:
--------------------------------------------------------------------------------
1 | export * from './utils';
2 | export * from './state';
3 | export * from './gentleman-state-object';
4 | //# sourceMappingURL=public-api.d.ts.map
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/models/public-api.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../../../projects/gentleman-state-manager/src/lib/models/public-api.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,0BAA0B,CAAC"}
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/models/source-of-truth.d.ts:
--------------------------------------------------------------------------------
1 | import { GentlemanStateObject } from "../models/public-api";
2 | import { StateProperties } from "./state";
3 | export declare type SourceOfTruth = Map;
4 | export interface SourceOfTruthInitiate {
5 | key: string;
6 | state: any;
7 | stateProperties: StateProperties;
8 | }
9 | //# sourceMappingURL=source-of-truth.d.ts.map
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/models/source-of-truth.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"source-of-truth.d.ts","sourceRoot":"","sources":["../../../../projects/gentleman-state-manager/src/lib/models/source-of-truth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,oBAAY,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;AAE9D,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,GAAG,CAAC;IACX,eAAe,EAAE,eAAe,CAAC;CAClC"}
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/models/state.d.ts:
--------------------------------------------------------------------------------
1 | export interface StateProperties {
2 | [key: string]: string;
3 | }
4 | //# sourceMappingURL=state.d.ts.map
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/models/state.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../projects/gentleman-state-manager/src/lib/models/state.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB"}
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/models/utils.d.ts:
--------------------------------------------------------------------------------
1 | export declare type TypeWithKey = {
2 | [key: string]: T;
3 | };
4 | export interface Condition {
5 | met: boolean;
6 | value: any;
7 | }
8 | //# sourceMappingURL=utils.d.ts.map
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/models/utils.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../projects/gentleman-state-manager/src/lib/models/utils.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW,CAAC,CAAC,IAAI;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;CAAE,CAAC;AAElD,MAAM,WAAW,SAAS;IACtB,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,GAAG,CAAC;CACd"}
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/public-api.d.ts:
--------------------------------------------------------------------------------
1 | export * from './services/public-api';
2 | export * from './models/public-api';
3 | export * from './gentleman-state-manager.module';
4 | //# sourceMappingURL=public-api.d.ts.map
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/public-api.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../../projects/gentleman-state-manager/src/lib/public-api.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kCAAkC,CAAC"}
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/services/gentleman-state.service.d.ts:
--------------------------------------------------------------------------------
1 | import { GentlemanStateObject, StateProperties } from "../models/public-api";
2 | import { SourceOfTruthInitiate } from "../models/source-of-truth";
3 | import * as i0 from "@angular/core";
4 | export declare class GentlemanStateService {
5 | private observerArray;
6 | constructor(sourceOfTruthKeys: SourceOfTruthInitiate[]);
7 | /**
8 | * @desc it checks if the searched object exists, if not it throws an errors and stops the execution.
9 | * @param gentlemanObject - GentlemanStateObject | undefined
10 | * @return GentlemanStateObject
11 | */
12 | private static checkIfFound;
13 | /**
14 | * @desc it creates and observable and adds it to the observable array.
15 | * @param key - the key to be used to represent the observable item inside the array
16 | * @param state - the state of the observable, the object that represents what the observable is going to contain
17 | * @param stateProperties - the properties of the state
18 | * @return void
19 | */
20 | createObservable(key: string, state: any, stateProperties: StateProperties): void;
21 | /**
22 | * @desc it returns the selected observable using the provided key.
23 | * @param key - the key to be used to represent the observable item inside the array
24 | * @return GentlemanStateObject
25 | */
26 | getEntity(key: string): GentlemanStateObject;
27 | /**
28 | * @desc it emits a new value into the selected observable using the provided key.
29 | * @param key - the key to be used to represent the observable item inside the array
30 | * @param data - the data to be emitted inside the selected observable
31 | * @return void
32 | */
33 | emitValue(key: string, data: any): void;
34 | /**
35 | * @desc it destroys an object from the observable array.
36 | * @param key - the key to be used to represent the observable item inside the array
37 | * @return void
38 | */
39 | destroyObservable(key: string): void;
40 | static ɵfac: i0.ɵɵFactoryDeclaration;
41 | static ɵprov: i0.ɵɵInjectableDeclaration;
42 | }
43 | //# sourceMappingURL=gentleman-state.service.d.ts.map
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/services/gentleman-state.service.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"gentleman-state.service.d.ts","sourceRoot":"","sources":["../../../../projects/gentleman-state-manager/src/lib/services/gentleman-state.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAiB,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;;AAGjF,qBAGa,qBAAqB;IAChC,OAAO,CAAC,aAAa,CAA4B;gBAER,iBAAiB,EAAE,qBAAqB,EAAE;IAOnF;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAO3B;;;;;;OAMG;IACH,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,eAAe,EAAE,eAAe,GAAG,IAAI;IAUjF;;;;OAIG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB;IAK5C;;;;;OAKG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI;IAKvC;;;;OAIG;IACH,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;yCAjEzB,qBAAqB;6CAArB,qBAAqB;CAsEjC"}
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/services/public-api.d.ts:
--------------------------------------------------------------------------------
1 | export * from './gentleman-state.service';
2 | //# sourceMappingURL=public-api.d.ts.map
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/services/public-api.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../../../projects/gentleman-state-manager/src/lib/services/public-api.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/utils/functionalities.d.ts:
--------------------------------------------------------------------------------
1 | import { Condition } from '../models/utils';
2 | /**
3 | * @desc checks if the condition is met and returns its value
4 | * @param condition - the condition to check
5 | * @param errorMessage - the error message to be shown if the condition is not met
6 | * @return any
7 | */
8 | export declare function checkIfConditionMet(condition: () => Condition, errorMessage: string): any;
9 | //# sourceMappingURL=functionalities.d.ts.map
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/utils/functionalities.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"functionalities.d.ts","sourceRoot":"","sources":["../../../../projects/gentleman-state-manager/src/lib/utils/functionalities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAE1C;;;;;GAKG;AAEH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,SAAS,EAAE,YAAY,EAAE,MAAM,GAAG,GAAG,CAOzF"}
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/utils/public-api.d.ts:
--------------------------------------------------------------------------------
1 | export * from './functionalities';
2 | //# sourceMappingURL=public-api.d.ts.map
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/lib/utils/public-api.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../../../projects/gentleman-state-manager/src/lib/utils/public-api.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gentleman-state-manager-lib",
3 | "version": "1.1.0",
4 | "peerDependencies": {
5 | "@angular/common": "~12.0.1",
6 | "@angular/core": "~12.0.1"
7 | },
8 | "dependencies": {
9 | "rxjs": "~6.6.3",
10 | "tslib": "^2.0.0"
11 | },
12 | "main": "bundles/gentleman-state-manager-lib.umd.js",
13 | "module": "fesm2015/gentleman-state-manager-lib.js",
14 | "es2015": "fesm2015/gentleman-state-manager-lib.js",
15 | "esm2015": "esm2015/gentleman-state-manager-lib.js",
16 | "fesm2015": "fesm2015/gentleman-state-manager-lib.js",
17 | "typings": "gentleman-state-manager-lib.d.ts",
18 | "sideEffects": false,
19 | "scripts": {
20 | "prepublishOnly": "node --eval \"console.error('ERROR: Trying to publish a package that has been compiled by Ivy in full compilation mode. This is not allowed.\\nPlease delete and rebuild the package with Ivy partial compilation mode, before attempting to publish.\\n')\" && exit 1"
21 | }
22 | }
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/public-api.d.ts:
--------------------------------------------------------------------------------
1 | export * from './lib/public-api';
2 | //# sourceMappingURL=public-api.d.ts.map
--------------------------------------------------------------------------------
/dist/gentleman-state-manager/public-api.d.ts.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../projects/gentleman-state-manager/src/public-api.ts"],"names":[],"mappings":"AAIA,cAAc,kBAAkB,CAAC"}
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gentleman-state-manager-library",
3 | "version": "0.0.0",
4 | "scripts": {
5 | "ng": "ng",
6 | "start": "ng serve",
7 | "build": "ng build",
8 | "test": "ng test",
9 | "lint": "ng lint",
10 | "e2e": "ng e2e"
11 | },
12 | "private": true,
13 | "dependencies": {
14 | "@angular/animations": "~12.0.1",
15 | "@angular/common": "~12.0.1",
16 | "@angular/compiler": "~12.0.1",
17 | "@angular/core": "~12.0.1",
18 | "@angular/forms": "~12.0.1",
19 | "@angular/platform-browser": "~12.0.1",
20 | "@angular/platform-browser-dynamic": "~12.0.1",
21 | "@angular/router": "~12.0.1",
22 | "rxjs": "~6.6.3",
23 | "tslib": "^2.0.0",
24 | "zone.js": "~0.11.4"
25 | },
26 | "devDependencies": {
27 | "@angular-devkit/build-angular": "~12.0.1",
28 | "@angular/cli": "~12.0.1",
29 | "@angular/compiler-cli": "~12.0.1",
30 | "@types/jasmine": "~3.6.0",
31 | "@types/jasminewd2": "~2.0.3",
32 | "@types/node": "^12.11.1",
33 | "codelyzer": "^6.0.0",
34 | "jasmine-core": "~3.6.0",
35 | "jasmine-spec-reporter": "~5.0.0",
36 | "karma": "~6.3.2",
37 | "karma-chrome-launcher": "~3.1.0",
38 | "karma-coverage-istanbul-reporter": "~3.0.2",
39 | "karma-jasmine": "~4.0.0",
40 | "karma-jasmine-html-reporter": "^1.5.0",
41 | "ng-packagr": "^12.0.0",
42 | "protractor": "~7.0.0",
43 | "ts-node": "~8.3.0",
44 | "tslint": "~6.1.0",
45 | "typescript": "~4.2.4"
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/README.md:
--------------------------------------------------------------------------------
1 | # Gentleman State Manager
2 |
3 | This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.0.5.
4 |
5 | ## Description
6 |
7 | Hi everyone ! this is a super easy and comfortable way of using reactive programming to manage the state of your application.
8 | This library is based on Rxjs Behaviour Subject observables to manage the different states of your application using the concept of a single source of truth.
9 |
10 | First...Let's learn some things !
11 |
12 | Reactive programming is the concept of developing code where different entities are watching trough an information channel for data to pass, and when it does,
13 | each entity will "react" to that situation doing their business logic.
14 |
15 | Imagine an empty tube with 3 holes in it, at each hole we have a person looking trough it and waiting for a little ball to pass. Because each person is different,
16 | they will see different aspects of the ball. For example, one can see that the ball is red, another that the ball is bouncing a little when it's passing trough
17 | ...or even that maybe it's not a ball at all !.
18 |
19 | That's exactly what reactive programming is ! we have an information channel (observables) containing the data that is passing trough it,
20 | and on the other hand we have entities (the angular components for example) that will be subscribed and waiting for that information to pass ...and when it does,
21 | they will react to it doing what ever business logic we coded for them.
22 |
23 | Redux, Ngrx/store, etc. are libraries that provide tools to manage the state of the application using the concept of "A Single Source Of Truth", these means that
24 | the whole information of the app will be contained inside a "store", a place where you can access useful and up to date information. Each time a change happens
25 | inside your application, information wise, the store will be updated with the latest changes. So you don't need to call the back end again for an update if not needed and also
26 | all entities that are watching the store's states will be automatically alerted of the change.
27 |
28 | Rxjs is a library containing a lot of amazing tools to manage these information channels, these provide the ability to combine and modify observables with the inclusion of
29 | new kinds of observables to use, each one with their own functionalities.
30 |
31 | We are going to use Behaviour Subjects a lot in this case, it's an observable that will always contain the last data that passed trough it....which is amazing for what we want to do !
32 | When ever we send information trough the Behaviour Subject, even if an entity subscribes AFTER the information has been sent, it will receive the latest data ! so we don't loose anything.
33 |
34 | The main concept of Gentleman State Manager, is providing an useful way to manage the state of your application, using understandable and cristal clear tools like Rxjs to do so.
35 | In short, we create an array of observables identified by their key, that can be increased in size by each module (so yes, we use lazy loading !) to manage the information
36 | that passes trough the different entities of your Angular application.
37 |
38 | ## How to use
39 |
40 | 1- Create an object using the SourceOfTruthInitiate class provided by the library. I recommend having a state.ts per module, representing the state interfaces and properties :
41 |
42 | ```
43 | state.ts for Root ( AppModule ):
44 |
45 | export interface FirstState {
46 | stateProperty: string | null;
47 | }
48 |
49 | export enum FirstStateProperties {
50 | STATEPROPERTY: 'stateProperty'
51 | }
52 |
53 | export enum StoreKeys {
54 | FIRSTSTATE: 'firstState'
55 | }
56 |
57 | AppModule:
58 |
59 | const sourceOfTruthInitiate: SourceOfTruthInitiate[] = [
60 | {
61 | key: StoreKeys.FIRSTSTATE,
62 | state: {
63 | stateProperty: 'your state property value'
64 | },
65 | stateProperties: FirstStateProperties
66 | }
67 | ];
68 | ```
69 |
70 | - key: represents the key to access the proper observable that we want to use.
71 | - state: the empty state of the object that will pass trough the observable.
72 | - stateProperties: the properties of the object, we are going to use it to access the information without ambiguities.
73 |
74 | 2- import GentlemanStateManagerModule inside your application in the following way:
75 |
76 | ```
77 | @NgModule({
78 | imports: [
79 | ...
80 | GentlemanStateManagerModule.forRoot(sourceOfTruthInitiate)
81 | ...
82 | ]
83 | })
84 | export class AppModule {}
85 | ```
86 |
87 | 3- use our apis to access the information or send something new !
88 |
89 | Example:
90 |
91 | ```
92 | export class OverviewMetricComponent implements OnDestroy {
93 | constructor(gentlemanStateManager: GentlemanStateService) {
94 | console.log(gentlemanStateManager.getEntity(StoreKeys.FIRSTSTATE).getPropertyFromState(FirstStateProperties.STATEPROPERTY));
95 | }
96 | }
97 | ```
98 |
99 | 4- to lazy load more observables just do the same functionality as in the app module, but in the constructor of your lazy loaded one.
100 |
101 | Example:
102 |
103 | ```
104 | state.ts for Root ( AppModule ):
105 |
106 | ...
107 | export enum StoreKeys {
108 | FIRSTSTATE: 'firstState',
109 | LAZYLOADEDSTATE: 'lazyLoadedState' // we add the new state key
110 | }
111 | ...
112 |
113 | state.ts of your lazy loaded module:
114 |
115 | export interface LazyLoadedState {
116 | lazyLoadedStateProperty: string | null;
117 | }
118 |
119 | export enum LazyLoadedStateProperties {
120 | LAZYLOADEDSTATEPROPERTY: 'lazyLoadedStateProperty'
121 | }
122 |
123 | const sourceOfTruthInitiate: SourceOfTruthInitiate[] = [
124 | {
125 | key: StoreKeys.LAZYLOADEDSTATE,
126 | state: {
127 | lazyLoadedStateProperty: 'Your Lazy Loaded State Property'
128 | },
129 | stateProperties: LazyLoadedStateProperties
130 | }
131 | ];
132 |
133 | @NgModule({
134 | ...
135 | })
136 | export class LazyLoadedModule {
137 | constructor(gentlemanStateService: GentlemanStateService) {
138 | sourceOfTruthInitiate.forEach(state => gentlemanStateService.createObservable(state.key, state.state, state.stateProperties));
139 | }
140 | }
141 |
142 | ```
143 |
144 | ## Api
145 |
146 | ### Array Of Observables Management :
147 |
148 | createObservable
149 |
150 | ```
151 | /**
152 | * @desc it creates and observable and adds it to the observable array.
153 | * @param key: the key to be used to represent the observable item inside the array
154 | * @param state: the state of the observable, the object that represents what the observable is going to contain
155 | * @return void
156 | */
157 | createObservable(key: string, state: any, stateProperties: StateProperties): void
158 | ```
159 |
160 | getEntity
161 |
162 | ```
163 | /**
164 | * @desc it returns the selected observable using the provided key.
165 | * @param key - the key to be used to represent the observable item inside the array
166 | * @return GentlemanStateObject
167 | */
168 | getEntity(key: string): GentlemanStateObject
169 | ```
170 |
171 | destroyObservable
172 |
173 | ```
174 | /**
175 | * @desc it destroys an object from the observable array.
176 | * @param key - the key to be used to represent the observable item inside the array
177 | * @return void
178 | */
179 | destroyObservable(key: string): void
180 | ```
181 |
182 | ### GentlemanStateObject :
183 |
184 | getObservable
185 |
186 | ```
187 | /**
188 | * @desc returns the observable that contains the state for async operations - it listens for changes
189 | * @return Observable
190 | */
191 | getObservable(): Observable
192 | ```
193 |
194 | getStateProperties
195 |
196 | ```
197 | /**
198 | * @desc returns the state properties object
199 | * @return StateProperties
200 | */
201 | getStateProperties(): StateProperties
202 | ```
203 |
204 | unsubscribe (use it when you are destroying the main component of your module)
205 |
206 | ```
207 | /**
208 | * @desc unsubscribes from the observable
209 | * @return void
210 | */
211 | unsubscribe(): void
212 | ```
213 |
214 | getStateSnapshot
215 |
216 | ```
217 | /**
218 | * @desc returns the value of the state at the time of the call
219 | * @return any
220 | */
221 | getStateSnapshot(): any
222 | ```
223 |
224 | getPropertyFromState
225 |
226 | ```
227 | /**
228 | * @desc returns the value of a property of the state at the time of the call
229 | * @param property - the name of the requested property
230 | * @return any
231 | */
232 | getPropertyFromState(property: string): any
233 | ```
234 |
235 | getPropertyFromState
236 |
237 | ```
238 | /**
239 | * @desc returns the value of a property of the state at the time of the call
240 | * @param property - the name of the requested property
241 | * @return any
242 | */
243 | getPropertyFromState(property: string): any
244 | ```
245 |
246 | getPropertyFromObservable
247 |
248 | ```
249 | /**
250 | * @desc returns the value of a property of the state for async operations - it listens for changes
251 | * @param property - the name of the requested property
252 | * @return Observable
253 | */
254 | getPropertyFromObservable(property: string): Observable
255 | ```
256 |
257 | setObservableValues
258 |
259 | ```
260 | /**
261 | * @desc sets the value for a certain property inside the state, triggers an async event
262 | * @param value - the value for the requested property
263 | * @param property - the name of the requested property
264 | * @param emit - if true it will trigger an async event
265 | * @return void
266 | */
267 | setObservableValues(value: any, property: string | null = null, emit = true): void
268 | ```
269 |
270 | setStateValues
271 |
272 | ```
273 | /**
274 | * @desc sets the value for a certain property inside the state, doesn't triggers an async event
275 | * @param value - the value for the requested property
276 | * @param property - the name of the requested property, if no property it will try to patch the values into the state
277 | * @return void
278 | */
279 | setStateValues(value: any, property: string | null): void
280 | ```
281 |
282 | resetState
283 |
284 | ```
285 | /**
286 | * @desc resets the state
287 | * @return void
288 | */
289 | resetState(): void
290 | ```
291 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, '../../coverage/gentleman-state-manager'),
20 | reports: ['html', 'lcovonly', 'text-summary'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false,
30 | restartOnFileChange: true
31 | });
32 | };
33 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/ng-package.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3 | "dest": "../../dist/gentleman-state-manager",
4 | "lib": {
5 | "entryFile": "src/public-api.ts"
6 | },
7 | "allowedNonPeerDependencies": ["rxjs"]
8 | }
9 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gentleman-state-manager-lib",
3 | "version": "1.0.2",
4 | "peerDependencies": {
5 | "@angular/common": "~12.0.1",
6 | "@angular/core": "~12.0.1"
7 | },
8 | "dependencies": {
9 | "rxjs": "~6.6.3",
10 | "tslib": "^2.0.0"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/src/lib/gentleman-state-manager.module.ts:
--------------------------------------------------------------------------------
1 | import {ModuleWithProviders, NgModule} from '@angular/core';
2 | import {SourceOfTruthInitiate} from './models/source-of-truth';
3 | import {GentlemanStateService} from './services/public-api';
4 |
5 |
6 | @NgModule({
7 | declarations: [],
8 | imports: [],
9 | exports: []
10 | })
11 | export class GentlemanStateManagerModule {
12 | static forRoot(sourceOfTruthKeys: SourceOfTruthInitiate[]): ModuleWithProviders {
13 | return {
14 | ngModule: GentlemanStateManagerModule,
15 | providers: [GentlemanStateService, {provide: 'sourceOfTruthKeys', useValue: sourceOfTruthKeys}]
16 | };
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/src/lib/models/gentleman-state-object.ts:
--------------------------------------------------------------------------------
1 | import { BehaviorSubject, Observable } from 'rxjs';
2 | import { map } from 'rxjs/operators';
3 | import { checkIfConditionMet } from '../utils/public-api';
4 | import { StateProperties, TypeWithKey } from './public-api';
5 |
6 | export class GentlemanStateObject {
7 | private state: any;
8 | private stateProperties: StateProperties = {};
9 | readonly observableSubject: BehaviorSubject;
10 |
11 | constructor(state: any, stateProperties: StateProperties) {
12 | this.state = state;
13 | this.stateProperties = stateProperties;
14 | this.observableSubject = new BehaviorSubject(state);
15 | }
16 |
17 | /**
18 | * @desc returns the observable that contains the state for async operations - it listens for changes
19 | * @return Observable
20 | */
21 | getObservable(): Observable {
22 | return this.observableSubject.asObservable();
23 | }
24 |
25 | /**
26 | * @desc returns the state properties object
27 | * @return StateProperties
28 | */
29 | getStateProperties(): StateProperties {
30 | return this.stateProperties;
31 | }
32 |
33 | /**
34 | * @desc unsubscribes from the observable
35 | * @return void
36 | */
37 | unsubscribe(): void {
38 | this.observableSubject.unsubscribe();
39 | }
40 |
41 | /**
42 | * @desc returns the value of the state at the time of the call
43 | * @return any
44 | */
45 | getStateSnapshot(): any {
46 | return { ...this.state };
47 | }
48 |
49 | /**
50 | * @desc returns the value of a property of the state at the time of the call
51 | * @param property - the name of the requested property
52 | * @return any
53 | */
54 | getPropertyFromState(property: string): any {
55 | return this.state[property];
56 | }
57 |
58 | /**
59 | * @desc returns the value of a property of the state for async operations - it listens for changes
60 | * @param property - the name of the requested property
61 | * @return Observable
62 | */
63 | getPropertyFromObservable(property: string): Observable {
64 | return this.getObservable().pipe(map((s) => this.checkIfPropertyExists(s, property)));
65 | }
66 |
67 | /**
68 | * @desc sets the value for a certain property inside the state, triggers an async event
69 | * @param value - the value for the requested property
70 | * @param property - the name of the requested property
71 | * @param emit - if true it will trigger an async event
72 | * @return void
73 | */
74 | setObservableValues(value: any, property: string | null = null, emit = true): void {
75 | this.setStateValues(value, property);
76 | if (emit) {
77 | this.observableSubject.next(this.state);
78 | }
79 | }
80 |
81 | /**
82 | * @desc sets the value for a certain property inside the state, doesn't triggers an async event
83 | * @param value - the value for the requested property
84 | * @param property - the name of the requested property, if no property it will try to patch the values into the state
85 | * @return void
86 | */
87 | setStateValues(value: any, property: string | null): void {
88 | if (property && this.checkIfPropertyExists(this.state, property) !== undefined) {
89 | (this.state as TypeWithKey)[property] = value;
90 | } else {
91 | this.state = {
92 | ...this.state,
93 | ...value,
94 | };
95 | }
96 | }
97 |
98 | /**
99 | * @desc resets the state
100 | * @return void
101 | */
102 | resetState(): void {
103 | (this.state as TypeWithKey) = {};
104 | }
105 |
106 | /**
107 | * @desc checks if the selected property exists inside the state
108 | * @param state - the state of the observable, the object that represents what the observable is going to contain
109 | * @param property - the selected property
110 | * @return any
111 | */
112 | private checkIfPropertyExists(state: any, property: string): any {
113 | const condition = () => {
114 | return { met: state.hasOwnProperty(property), value: state[property] };
115 | };
116 | return checkIfConditionMet(() => condition(), 'Selected property not found ! check if the key is correct and exists');
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/src/lib/models/public-api.ts:
--------------------------------------------------------------------------------
1 | export * from './utils';
2 | export * from './state';
3 | export * from './gentleman-state-object';
4 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/src/lib/models/source-of-truth.ts:
--------------------------------------------------------------------------------
1 | import { GentlemanStateObject } from "../models/public-api";
2 | import { StateProperties } from "./state";
3 |
4 | export type SourceOfTruth = Map;
5 |
6 | export interface SourceOfTruthInitiate {
7 | key: string;
8 | state: any;
9 | stateProperties: StateProperties;
10 | }
11 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/src/lib/models/state.ts:
--------------------------------------------------------------------------------
1 | export interface StateProperties {
2 | [key: string]: string;
3 | }
4 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/src/lib/models/utils.ts:
--------------------------------------------------------------------------------
1 | export type TypeWithKey = { [key: string]: T };
2 |
3 | export interface Condition {
4 | met: boolean;
5 | value: any;
6 | }
7 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/src/lib/public-api.ts:
--------------------------------------------------------------------------------
1 | export * from './services/public-api';
2 | export * from './models/public-api';
3 | export * from './gentleman-state-manager.module';
4 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/src/lib/services/gentleman-state.service.ts:
--------------------------------------------------------------------------------
1 | import { Inject, Injectable } from "@angular/core";
2 | import { GentlemanStateObject, StateProperties } from "../models/public-api";
3 | import { SourceOfTruth, SourceOfTruthInitiate } from "../models/source-of-truth";
4 | import { checkIfConditionMet } from "../utils/public-api";
5 |
6 | @Injectable({
7 | providedIn: "root",
8 | })
9 | export class GentlemanStateService {
10 | private observerArray: SourceOfTruth = new Map();
11 |
12 | constructor(@Inject("sourceOfTruthKeys") sourceOfTruthKeys: SourceOfTruthInitiate[]) {
13 | sourceOfTruthKeys.forEach((k) => {
14 | const { state, stateProperties } = k;
15 | this.createObservable(k.key, state, stateProperties);
16 | });
17 | }
18 |
19 | /**
20 | * @desc it checks if the searched object exists, if not it throws an errors and stops the execution.
21 | * @param gentlemanObject - GentlemanStateObject | undefined
22 | * @return GentlemanStateObject
23 | */
24 | private static checkIfFound(gentlemanObject: GentlemanStateObject | undefined): GentlemanStateObject {
25 | const condition = () => {
26 | return { met: !!gentlemanObject, value: gentlemanObject };
27 | };
28 | return checkIfConditionMet(() => condition(), "Observable item not found ! check if the key is correct and exists");
29 | }
30 |
31 | /**
32 | * @desc it creates and observable and adds it to the observable array.
33 | * @param key - the key to be used to represent the observable item inside the array
34 | * @param state - the state of the observable, the object that represents what the observable is going to contain
35 | * @param stateProperties - the properties of the state
36 | * @return void
37 | */
38 | createObservable(key: string, state: any, stateProperties: StateProperties): void {
39 | const found = this.observerArray.has(key);
40 | if (found) {
41 | console.log(`the key : ${key}, already exists as an entity so it will be ignored`);
42 | } else {
43 | const gentlemanObject = new GentlemanStateObject(state, stateProperties);
44 | this.observerArray.set(key, gentlemanObject);
45 | }
46 | }
47 |
48 | /**
49 | * @desc it returns the selected observable using the provided key.
50 | * @param key - the key to be used to represent the observable item inside the array
51 | * @return GentlemanStateObject
52 | */
53 | getEntity(key: string): GentlemanStateObject {
54 | const observableArrayItem = GentlemanStateService.checkIfFound(this.observerArray.get(key));
55 | return observableArrayItem;
56 | }
57 |
58 | /**
59 | * @desc it emits a new value into the selected observable using the provided key.
60 | * @param key - the key to be used to represent the observable item inside the array
61 | * @param data - the data to be emitted inside the selected observable
62 | * @return void
63 | */
64 | emitValue(key: string, data: any): void {
65 | const observableArrayItem = GentlemanStateService.checkIfFound(this.observerArray.get(key));
66 | observableArrayItem.setObservableValues(data);
67 | }
68 |
69 | /**
70 | * @desc it destroys an object from the observable array.
71 | * @param key - the key to be used to represent the observable item inside the array
72 | * @return void
73 | */
74 | destroyObservable(key: string): void {
75 | const selectedObservable = GentlemanStateService.checkIfFound(this.observerArray.get(key));
76 | selectedObservable.unsubscribe();
77 | this.observerArray.delete(key);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/src/lib/services/public-api.ts:
--------------------------------------------------------------------------------
1 | export * from './gentleman-state.service';
2 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/src/lib/utils/functionalities.ts:
--------------------------------------------------------------------------------
1 | import {Condition} from '../models/utils';
2 |
3 | /**
4 | * @desc checks if the condition is met and returns its value
5 | * @param condition - the condition to check
6 | * @param errorMessage - the error message to be shown if the condition is not met
7 | * @return any
8 | */
9 |
10 | export function checkIfConditionMet(condition: () => Condition, errorMessage: string): any {
11 | const conditionMet = condition();
12 | if (!conditionMet.met) {
13 | console.error(errorMessage);
14 | throw Error(errorMessage);
15 | }
16 | return conditionMet.value;
17 | }
18 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/src/lib/utils/public-api.ts:
--------------------------------------------------------------------------------
1 | export * from './functionalities';
2 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/src/public-api.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Public API Surface of gentleman-state-manager
3 | */
4 |
5 | export * from './lib/public-api';
6 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js';
4 | import 'zone.js/testing';
5 | import {getTestBed} from '@angular/core/testing';
6 | import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing';
7 |
8 | declare const require: {
9 | context(path: string, deep?: boolean, filter?: RegExp): {
10 | keys(): string[];
11 | (id: string): T;
12 | };
13 | };
14 |
15 | // First, initialize the Angular testing environment.
16 | getTestBed().initTestEnvironment(
17 | BrowserDynamicTestingModule,
18 | platformBrowserDynamicTesting()
19 | );
20 | // Then we find all the tests.
21 | const context = require.context('./', true, /\.spec\.ts$/);
22 | // And load the modules.
23 | context.keys().map(context);
24 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/tsconfig.lib.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../out-tsc/lib",
5 | "declarationMap": true,
6 | "target": "es2015",
7 | "declaration": true,
8 | "inlineSources": true,
9 | "types": [],
10 | "lib": [
11 | "dom",
12 | "es2018"
13 | ]
14 | },
15 | "angularCompilerOptions": {
16 | "skipTemplateCodegen": true,
17 | "strictMetadataEmit": true,
18 | "enableResourceInlining": true
19 | },
20 | "exclude": [
21 | "src/test.ts",
22 | "**/*.spec.ts"
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/tsconfig.lib.prod.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.lib.json",
3 | "compilerOptions": {
4 | "declarationMap": false
5 | },
6 | "angularCompilerOptions": {
7 | "enableIvy": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../out-tsc/spec",
5 | "types": [
6 | "jasmine",
7 | "node"
8 | ]
9 | },
10 | "files": [
11 | "src/test.ts"
12 | ],
13 | "include": [
14 | "**/*.spec.ts",
15 | "**/*.d.ts"
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/projects/gentleman-state-manager/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "lib",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "lib",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "baseUrl": "./",
5 | "outDir": "./dist/out-tsc",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "downlevelIteration": true,
9 | "experimentalDecorators": true,
10 | "module": "es2020",
11 | "moduleResolution": "node",
12 | "importHelpers": true,
13 | "target": "es2015",
14 | "lib": [
15 | "es2018",
16 | "dom"
17 | ],
18 | "paths": {
19 | "gentleman-state-manager": [
20 | "dist/gentleman-state-manager/gentleman-state-manager",
21 | "dist/gentleman-state-manager"
22 | ]
23 | }
24 | },
25 | "angularCompilerOptions": {
26 | "fullTemplateTypeCheck": true,
27 | "strictInjectionParameters": true
28 | }
29 | }
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "tslint:recommended",
3 | "rulesDirectory": [
4 | "codelyzer"
5 | ],
6 | "rules": {
7 | "align": {
8 | "options": [
9 | "parameters",
10 | "statements"
11 | ]
12 | },
13 | "array-type": false,
14 | "arrow-return-shorthand": true,
15 | "curly": true,
16 | "deprecation": {
17 | "severity": "warning"
18 | },
19 | "eofline": true,
20 | "import-blacklist": [
21 | true,
22 | "rxjs/Rx"
23 | ],
24 | "import-spacing": true,
25 | "indent": {
26 | "options": [
27 | "spaces"
28 | ]
29 | },
30 | "max-classes-per-file": false,
31 | "max-line-length": [
32 | true,
33 | 140
34 | ],
35 | "member-ordering": [
36 | true,
37 | {
38 | "order": [
39 | "static-field",
40 | "instance-field",
41 | "static-method",
42 | "instance-method"
43 | ]
44 | }
45 | ],
46 | "no-console": [
47 | true,
48 | "debug",
49 | "info",
50 | "time",
51 | "timeEnd",
52 | "trace"
53 | ],
54 | "no-empty": false,
55 | "no-inferrable-types": [
56 | true,
57 | "ignore-params"
58 | ],
59 | "no-non-null-assertion": true,
60 | "no-redundant-jsdoc": true,
61 | "no-switch-case-fall-through": true,
62 | "no-var-requires": false,
63 | "object-literal-key-quotes": [
64 | true,
65 | "as-needed"
66 | ],
67 | "quotemark": [
68 | true,
69 | "single"
70 | ],
71 | "semicolon": {
72 | "options": [
73 | "always"
74 | ]
75 | },
76 | "space-before-function-paren": {
77 | "options": {
78 | "anonymous": "never",
79 | "asyncArrow": "always",
80 | "constructor": "never",
81 | "method": "never",
82 | "named": "never"
83 | }
84 | },
85 | "typedef-whitespace": {
86 | "options": [
87 | {
88 | "call-signature": "nospace",
89 | "index-signature": "nospace",
90 | "parameter": "nospace",
91 | "property-declaration": "nospace",
92 | "variable-declaration": "nospace"
93 | },
94 | {
95 | "call-signature": "onespace",
96 | "index-signature": "onespace",
97 | "parameter": "onespace",
98 | "property-declaration": "onespace",
99 | "variable-declaration": "onespace"
100 | }
101 | ]
102 | },
103 | "variable-name": {
104 | "options": [
105 | "ban-keywords",
106 | "check-format",
107 | "allow-pascal-case"
108 | ]
109 | },
110 | "whitespace": {
111 | "options": [
112 | "check-branch",
113 | "check-decl",
114 | "check-operator",
115 | "check-separator",
116 | "check-type",
117 | "check-typecast"
118 | ]
119 | },
120 | "component-class-suffix": true,
121 | "contextual-lifecycle": true,
122 | "directive-class-suffix": true,
123 | "no-conflicting-lifecycle": true,
124 | "no-host-metadata-property": true,
125 | "no-input-rename": true,
126 | "no-inputs-metadata-property": true,
127 | "no-output-native": true,
128 | "no-output-on-prefix": true,
129 | "no-output-rename": true,
130 | "no-outputs-metadata-property": true,
131 | "template-banana-in-box": true,
132 | "template-no-negated-async": true,
133 | "use-lifecycle-interface": true,
134 | "use-pipe-transform-interface": true
135 | }
136 | }
137 |
--------------------------------------------------------------------------------