Skip to content
This repository was archived by the owner on May 24, 2022. It is now read-only.

Commit 2bd65be

Browse files
authored
feat: use @angular-ru/common as main dependency (#510)
* feat: use @angular-ru/common as main dependency * !fixup
1 parent d333c18 commit 2bd65be

File tree

106 files changed

+1653
-1804
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+1653
-1804
lines changed

CHANGELOG.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
# To become 3.1.0
1+
# To become 4.0.0
22

3-
- Feature: support Angular Schematics `ng add @ngxs-labs/data`
3+
### ⚠ BREAKING CHANGES
4+
5+
- Moved `Immutable, Mutable, Any` interfaces to `@angular-ru/common/typings`:
6+
7+
```ts
8+
import { Immutable, Mutable, Any } from '@angular-ru/common/typings';
9+
```
410

511
# 3.0.6 2020-06-25
612

713
- Fix: entry point '@ngxs/store/src/\*' contains deep imports into in lib
14+
- Feature: support Angular Schematics `ng add @ngxs-labs/data`
815

916
# 3.0.0 2020-05-05
1017

docs/pages/data-action.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ By default, all arguments have no name when automatically creating an action.
402402

403403
![](https://habrastorage.org/webt/dh/p4/9d/dhp49dtfspp6mas7-0em2vlqcra.png)
404404

405-
If during logging you want to see the payload, then you need to specify which action argument is this payload, using the `@Payload()` decorator.
405+
If during logging you want to see the payload, then you need to specify which action argument is this payload, using the
406+
`@Payload()` decorator.
406407

407408
```ts
408409
@StateRepository()

docs/pages/immutability.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Thus, the developer will not be able to make his own mistake. If he will mutate
7979
methods. If you need to use states for set input property:
8080

8181
```ts
82-
import { Immutable } from '@ngxs-labs/data/typings';
82+
import { Immutable } from '@angular-ru/common/typings';
8383

8484
@Component({ .. })
8585
class TodoComponent {

docs/pages/testing.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ describe('AppState', () => {
2727
#### Example where we testing NGXS Lifecycle
2828

2929
```ts
30-
import { NgxsSimpleChange, State, Store } from '@ngxs/store';
31-
import { StateRepository } from '@ngxs-labs/data/decorators';
32-
import { NgxsDataRepository, NgxsImmutableDataRepository } from '@ngxs-labs/data/repositories';
33-
import { Any, Immutable, NgxsDataAfterReset, NgxsDataDoCheck } from '@ngxs-labs/data/typings';
34-
import { Injectable } from '@angular/core';
35-
import { ngxsTestingPlatform } from '@ngxs-labs/data/testing';
30+
// ..
3631

3732
describe('[TEST]: Abstract ngxs data repository', () => {
3833
let event: string[] = [];

integration/app/polyfills.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'core-js/proposals/reflect-metadata';
22
import 'zone.js/dist/zone';
33

4-
import { Any } from '@ngxs-labs/data/typings';
4+
import { Any } from '@angular-ru/common/typings';
55

66
(window as Any)['__importDefault'] =
77
(this && (this as Any).__importDefault) ||

integration/app/src/examples/count/count.state.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { Immutable } from '@angular-ru/common/typings';
12
import { Injectable } from '@angular/core';
23
import { Computed, DataAction, Debounce, Payload, StateRepository } from '@ngxs-labs/data/decorators';
34
import { NgxsImmutableDataRepository } from '@ngxs-labs/data/repositories';
4-
import { Immutable } from '@ngxs-labs/data/typings';
55
import { State, StateToken } from '@ngxs/store';
66
import { Observable } from 'rxjs';
77
import { map } from 'rxjs/operators';
@@ -20,8 +20,8 @@ const COUNT_TOKEN: StateToken<ParentCountModel> = new StateToken<ParentCountMode
2020
@Injectable()
2121
export class CountState extends NgxsImmutableDataRepository<ParentCountModel> {
2222
@Computed()
23-
public get values$(): Observable<ParentCountModel> {
24-
return this.state$.pipe(map((state: Immutable<ParentCountModel>): CountModel => state.countSub!));
23+
public get values$(): Observable<ParentCountModel | undefined> {
24+
return this.state$.pipe(map((state: Immutable<ParentCountModel>): CountModel | undefined => state.countSub));
2525
}
2626

2727
@DataAction()

integration/app/src/examples/todo/todo.state.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { Immutable } from '@angular-ru/common/typings';
12
import { Injectable } from '@angular/core';
23
import { MatSnackBar } from '@angular/material/snack-bar';
34
import { DataAction, Payload, Persistence, StateRepository } from '@ngxs-labs/data/decorators';
45
import { NgxsImmutableDataRepository } from '@ngxs-labs/data/repositories';
5-
import { Immutable, NgxsDataAfterExpired, NgxsDataExpiredEvent, PersistenceProvider } from '@ngxs-labs/data/typings';
6+
import { NgxsDataAfterExpired, NgxsDataExpiredEvent, PersistenceProvider } from '@ngxs-labs/data/typings';
67
import { State } from '@ngxs/store';
78
import { Subject } from 'rxjs';
89

integration/tests/common-extensions/action-decorator.spec.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('[TEST]: Action decorator', () => {
2525
imports: [NgxsModule.forRoot([InvalidState]), NgxsDataPluginModule.forRoot()]
2626
});
2727

28-
const state: InvalidState = TestBed.get(InvalidState);
28+
const state: InvalidState = TestBed.inject(InvalidState);
2929
state.setState('new value');
3030
} catch (e) {
3131
message = e.message;
@@ -50,7 +50,7 @@ describe('[TEST]: Action decorator', () => {
5050
imports: [NgxsModule.forRoot([InvalidState]), NgxsDataPluginModule.forRoot()]
5151
});
5252

53-
const state: InvalidState = TestBed.get(InvalidState);
53+
const state: InvalidState = TestBed.inject(InvalidState);
5454
state.setState('new value');
5555
} catch (e) {
5656
message = e.message;
@@ -74,7 +74,7 @@ describe('[TEST]: Action decorator', () => {
7474
imports: [NgxsModule.forRoot([InvalidState]), NgxsDataPluginModule.forRoot()]
7575
});
7676

77-
const state: InvalidState = TestBed.get(InvalidState);
77+
const state: InvalidState = TestBed.inject(InvalidState);
7878
state.setup();
7979
} catch (e) {
8080
message = e.message;
@@ -99,7 +99,7 @@ describe('[TEST]: Action decorator', () => {
9999
providers: [InvalidState]
100100
});
101101

102-
const state: InvalidState = TestBed.get(InvalidState);
102+
const state: InvalidState = TestBed.inject(InvalidState);
103103
state.setup();
104104
} catch (e) {
105105
message = e.message;
@@ -123,7 +123,7 @@ describe('[TEST]: Action decorator', () => {
123123
imports: [NgxsModule.forRoot([A]), NgxsDataPluginModule.forRoot()]
124124
});
125125

126-
const stateA: A = TestBed.get(A);
126+
const stateA: A = TestBed.inject(A);
127127

128128
expect(getRepository(A)).toEqual({
129129
stateMeta: {
@@ -240,9 +240,9 @@ describe('[TEST]: Action decorator', () => {
240240
imports: [NgxsModule.forRoot([A, B, C]), NgxsDataPluginModule.forRoot()]
241241
});
242242

243-
stateA = TestBed.get(A);
244-
stateB = TestBed.get(B);
245-
stateC = TestBed.get(C);
243+
stateA = TestBed.inject(A);
244+
stateB = TestBed.inject(B);
245+
stateC = TestBed.inject(C);
246246
});
247247

248248
it('should be correct metadata before invoked actions', () => {

integration/tests/common-extensions/argument-decorators.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('[TEST]: Argument decorators', () => {
1919
imports: [NgxsModule.forRoot([A]), NgxsDataPluginModule.forRoot()]
2020
});
2121

22-
const a: A = TestBed.get<A>(A);
22+
const a: A = TestBed.inject<A>(A);
2323

2424
a.setState('1');
2525

@@ -52,7 +52,7 @@ describe('[TEST]: Argument decorators', () => {
5252
imports: [NgxsModule.forRoot([B]), NgxsDataPluginModule.forRoot()]
5353
});
5454

55-
const b: B = TestBed.get<B>(B);
55+
const b: B = TestBed.inject<B>(B);
5656

5757
b.set('2');
5858

@@ -85,7 +85,7 @@ describe('[TEST]: Argument decorators', () => {
8585
imports: [NgxsModule.forRoot([C]), NgxsDataPluginModule.forRoot()]
8686
});
8787

88-
const c: C = TestBed.get<C>(C);
88+
const c: C = TestBed.inject<C>(C);
8989

9090
c.set('4', '10');
9191

@@ -118,7 +118,7 @@ describe('[TEST]: Argument decorators', () => {
118118
imports: [NgxsModule.forRoot([D]), NgxsDataPluginModule.forRoot()]
119119
});
120120

121-
const d: D = TestBed.get<D>(D);
121+
const d: D = TestBed.inject<D>(D);
122122

123123
d.set('1', '2', '3');
124124

integration/tests/common-extensions/computed-observable.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ describe('[TEST]: Observable with computed $a field', () => {
9191
imports: [NgxsModule.forRoot([A, B]), NgxsDataPluginModule.forRoot()]
9292
});
9393

94-
a = TestBed.get(A);
95-
b = TestBed.get(B);
94+
a = TestBed.inject(A);
95+
b = TestBed.inject(B);
9696
subResult = [];
9797

9898
ref1 = null;

integration/tests/common-extensions/computed.spec.ts

+17-17
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('[TEST]: Computed fields', () => {
5353
imports: [NgxsModule.forRoot([B]), NgxsDataPluginModule.forRoot()]
5454
});
5555

56-
const b: B = TestBed.get<B>(B); // sequenceId = 0
56+
const b: B = TestBed.inject<B>(B); // sequenceId = 0
5757

5858
expect(b.snapshot).toEqual('value');
5959
expect(b.snapshot).toEqual('value');
@@ -122,7 +122,7 @@ describe('[TEST]: Computed fields', () => {
122122
imports: [NgxsModule.forRoot([OrderLineState]), NgxsDataPluginModule.forRoot()]
123123
});
124124

125-
const state: OrderLineState = TestBed.get<OrderLineState>(OrderLineState);
125+
const state: OrderLineState = TestBed.inject<OrderLineState>(OrderLineState);
126126

127127
// noinspection DuplicatedCode
128128
expect(state.total).toEqual(0);
@@ -196,7 +196,7 @@ describe('[TEST]: Computed fields', () => {
196196
imports: [NgxsModule.forRoot([ImmutableOrderLineState]), NgxsDataPluginModule.forRoot()]
197197
});
198198

199-
const state: ImmutableOrderLineState = TestBed.get<ImmutableOrderLineState>(ImmutableOrderLineState);
199+
const state: ImmutableOrderLineState = TestBed.inject<ImmutableOrderLineState>(ImmutableOrderLineState);
200200

201201
// noinspection DuplicatedCode
202202
expect(state.total).toEqual(0);
@@ -259,9 +259,9 @@ describe('[TEST]: Computed fields', () => {
259259
imports: [NgxsModule.forRoot([A, B]), NgxsDataPluginModule.forRoot()]
260260
});
261261

262-
const store: Store = TestBed.get<Store>(Store);
263-
const a: A = TestBed.get<A>(A);
264-
const b: B = TestBed.get<B>(B);
262+
const store: Store = TestBed.inject<Store>(Store);
263+
const a: A = TestBed.inject<A>(A);
264+
const b: B = TestBed.inject<B>(B);
265265

266266
expect(store.snapshot()).toEqual({ b: 0, a: 0 });
267267
expect(a.snapshot).toEqual(0);
@@ -305,9 +305,9 @@ describe('[TEST]: Computed fields', () => {
305305
imports: [NgxsModule.forRoot([A, B]), NgxsDataPluginModule.forRoot()]
306306
});
307307

308-
const store: Store = TestBed.get<Store>(Store);
309-
const a: A = TestBed.get<A>(A);
310-
const b: B = TestBed.get<B>(B);
308+
const store: Store = TestBed.inject<Store>(Store);
309+
const a: A = TestBed.inject<A>(A);
310+
const b: B = TestBed.inject<B>(B);
311311

312312
expect(store.snapshot()).toEqual({ b: 0, a: 0 });
313313
expect(a.snapshot).toEqual(0);
@@ -388,10 +388,10 @@ describe('[TEST]: Computed fields', () => {
388388
imports: [NgxsModule.forRoot([A, B]), NgxsDataPluginModule.forRoot()]
389389
});
390390

391-
const store: Store = TestBed.get(Store);
392-
const a: A = TestBed.get(A);
393-
const b: B = TestBed.get(B);
394-
const stream: NgxsDataSequence = TestBed.get(NgxsDataSequence);
391+
const store: Store = TestBed.inject(Store);
392+
const a: A = TestBed.inject(A);
393+
const b: B = TestBed.inject(B);
394+
const stream: NgxsDataSequence = TestBed.inject(NgxsDataSequence);
395395

396396
expect(stream.sequenceValue).toEqual(1);
397397
expect(store.snapshot()).toEqual({ b: { value: 2 }, a: { value: 1 } });
@@ -490,8 +490,8 @@ describe('[TEST]: Computed fields', () => {
490490
providers: [MyFirstCountService]
491491
});
492492

493-
const first: MyFirstCountService = TestBed.get(MyFirstCountService);
494-
const second: MySecondCountState = TestBed.get(MySecondCountState);
493+
const first: MyFirstCountService = TestBed.inject(MyFirstCountService);
494+
const second: MySecondCountState = TestBed.inject(MySecondCountState);
495495

496496
expect(first.getValue()).toEqual(0);
497497
expect(second.snapshot).toEqual(0);
@@ -559,8 +559,8 @@ describe('[TEST]: Computed fields', () => {
559559
providers: [MyFirstCountService]
560560
});
561561

562-
const first: MyFirstCountService = TestBed.get(MyFirstCountService);
563-
const second: MySecondCountState = TestBed.get(MySecondCountState);
562+
const first: MyFirstCountService = TestBed.inject(MyFirstCountService);
563+
const second: MySecondCountState = TestBed.inject(MySecondCountState);
564564

565565
expect(first.getValue()).toEqual(0);
566566
expect(second.snapshot).toEqual(0);

integration/tests/common-extensions/counter-lifecycle.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ describe('Complex lifecycle', () => {
3434
});
3535

3636
try {
37-
TestBed.get<CountState>(CountState);
38-
TestBed.get<Store>(Store);
37+
TestBed.inject<CountState>(CountState);
38+
TestBed.inject<Store>(Store);
3939
} catch (e) {
4040
expect(e.message).toEqual(NGXS_DATA_EXCEPTIONS.NGXS_DATA_MODULE_EXCEPTION);
4141
}
@@ -102,7 +102,7 @@ describe('Complex lifecycle', () => {
102102
providers: [MyApiService]
103103
});
104104

105-
AppTestModule.ngDoBootstrap(TestBed.get(ApplicationRef));
105+
AppTestModule.ngDoBootstrap(TestBed.inject(ApplicationRef));
106106

107107
expect(hooks).toEqual([
108108
'CountState - create',

integration/tests/common-extensions/counter.spec.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('[TEST]: CountState', () => {
1919
imports: [NgxsModule.forRoot([CountState])]
2020
});
2121

22-
store = TestBed.get<Store>(Store);
22+
store = TestBed.inject<Store>(Store);
2323

2424
expect(store.snapshot()).toEqual({ count: 0 });
2525
});
@@ -56,8 +56,8 @@ describe('[TEST]: CountState', () => {
5656
imports: [NgxsModule.forRoot([CountState])]
5757
});
5858

59-
store = TestBed.get<Store>(Store);
60-
const count: CountState = TestBed.get<CountState>(CountState);
59+
store = TestBed.inject<Store>(Store);
60+
const count: CountState = TestBed.inject<CountState>(CountState);
6161

6262
expect(store.snapshot()).toEqual({ count: 0 });
6363

@@ -80,7 +80,7 @@ describe('[TEST]: CountState', () => {
8080
imports: [NgxsModule.forRoot([CountState]), NgxsDataPluginModule.forRoot()]
8181
});
8282

83-
const count: CountState = TestBed.get<CountState>(CountState);
83+
const count: CountState = TestBed.inject<CountState>(CountState);
8484

8585
try {
8686
count.getState();
@@ -102,7 +102,7 @@ describe('[TEST]: CountState', () => {
102102
providers: [CountState]
103103
});
104104

105-
const count: CountState = TestBed.get<CountState>(CountState);
105+
const count: CountState = TestBed.inject<CountState>(CountState);
106106

107107
try {
108108
count.getState();
@@ -133,7 +133,7 @@ describe('[TEST]: CountState', () => {
133133
imports: [NgxsModule.forRoot([CountState])]
134134
});
135135

136-
const count: CountState = TestBed.get<CountState>(CountState);
136+
const count: CountState = TestBed.inject<CountState>(CountState);
137137

138138
try {
139139
count.incorrect();
@@ -187,9 +187,9 @@ describe('[TEST]: CountState', () => {
187187
imports: [NgxsModule.forRoot([CountState]), NgxsDataPluginModule.forRoot()]
188188
});
189189

190-
count = TestBed.get<CountState>(CountState);
191-
store = TestBed.get<Store>(Store);
192-
actions$ = TestBed.get<Actions>(Actions);
190+
count = TestBed.inject<CountState>(CountState);
191+
store = TestBed.inject<Store>(Store);
192+
actions$ = TestBed.inject<Actions>(Actions);
193193
});
194194

195195
afterEach(() => {

integration/tests/common-extensions/debounce.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('[TEST]: Debounce', () => {
5454
imports: [NgxsModule.forRoot([DebounceState]), NgxsDataPluginModule.forRoot()]
5555
});
5656

57-
const state: DebounceState = TestBed.get<DebounceState>(DebounceState);
57+
const state: DebounceState = TestBed.inject<DebounceState>(DebounceState);
5858

5959
expect(state.getState()).toEqual(0);
6060

0 commit comments

Comments
 (0)