File tree 6 files changed +66
-66
lines changed
6 files changed +66
-66
lines changed Original file line number Diff line number Diff line change 1
- import { InjectionToken } from '@angular/core' ;
2
1
import { Observable } from 'rxjs' ;
3
2
4
- import { DaffIdentifiable } from '@daffodil/core' ;
3
+ import {
4
+ DaffIdentifiable ,
5
+ createSingleInjectionToken ,
6
+ } from '@daffodil/core' ;
5
7
import { DaffCustomerAddress } from '@daffodil/customer' ;
6
8
7
- /**
8
- * An injection token for the customer driver.
9
- */
10
- export const DaffCustomerAddressDriver = new InjectionToken < DaffCustomerAddressDriverInterface > ( 'DaffCustomerAddressDriver' ) ;
9
+ export const {
10
+ /**
11
+ * An injection token for the customer driver.
12
+ */
13
+ token : DaffCustomerAddressDriver ,
14
+ provider : daffProvideCustomerAddressDriver ,
15
+ } = createSingleInjectionToken < DaffCustomerAddressDriverInterface > ( 'DaffCustomerAddressDriver' ) ;
11
16
12
17
/**
13
18
* The customer driver is responsible for loading customers.
Original file line number Diff line number Diff line change 1
- import { InjectionToken } from '@angular/core' ;
2
1
import { Observable } from 'rxjs' ;
3
2
3
+ import { createSingleInjectionToken } from '@daffodil/core' ;
4
4
import { DaffCustomer } from '@daffodil/customer' ;
5
5
6
- /**
7
- * An injection token for the customer driver.
8
- */
9
- export const DaffCustomerDriver = new InjectionToken < DaffCustomerDriverInterface > ( 'DaffCustomerDriver' ) ;
6
+ export const {
7
+ /**
8
+ * An injection token for the customer driver.
9
+ */
10
+ token : DaffCustomerDriver ,
11
+ provider : daffProvideCustomerDriver ,
12
+ } = createSingleInjectionToken < DaffCustomerDriverInterface > ( 'DaffCustomerDriver' ) ;
10
13
11
14
/**
12
15
* The customer driver is responsible for loading customers.
Original file line number Diff line number Diff line change 1
- import { InjectionToken } from '@angular/core' ;
2
-
1
+ import { createSingleInjectionToken } from '@daffodil/core' ;
3
2
import { daffTransformErrorToStateError } from '@daffodil/core/state' ;
4
3
5
- /**
6
- * Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.
7
- * Can be used to further refine Daffodil errors into more specific app errors.
8
- */
9
- export const DAFF_CUSTOMER_ERROR_MATCHER = new InjectionToken < typeof daffTransformErrorToStateError > (
4
+ export const {
5
+ /**
6
+ * Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.
7
+ * Can be used to further refine Daffodil errors into more specific app errors.
8
+ */
9
+ token : DAFF_CUSTOMER_ERROR_MATCHER ,
10
+ provider : daffProvideCustomerErrorMatcher ,
11
+ } = createSingleInjectionToken < typeof daffTransformErrorToStateError > (
10
12
'DAFF_CUSTOMER_ERROR_MATCHER' ,
11
13
{ factory : ( ) => daffTransformErrorToStateError } ,
12
14
) ;
Original file line number Diff line number Diff line change 1
- export { DAFF_CUSTOMER_ERROR_MATCHER } from './error-matcher.token' ;
1
+ export * from './error-matcher.token' ;
Original file line number Diff line number Diff line change 1
- import {
2
- InjectionToken ,
3
- Provider ,
4
- } from '@angular/core' ;
5
1
import { ActionReducer } from '@ngrx/store' ;
6
2
3
+ import { createMultiInjectionToken } from '@daffodil/core' ;
4
+
7
5
import { DaffCustomerReducersState } from '../reducers.interface' ;
8
6
9
- /**
10
- * A token to hold the injectable extra reducers.
11
- *
12
- * Prefer using {@link daffCustomerProvideExtraReducers}.
13
- */
14
- export const DAFF_CUSTOMER_EXTRA_REDUCERS = new InjectionToken < ActionReducer < DaffCustomerReducersState > [ ] > (
7
+ export const {
8
+ /**
9
+ * A token to hold the injectable extra reducers.
10
+ *
11
+ * Prefer using {@link daffCustomerProvideExtraReducers}.
12
+ */
13
+ token : DAFF_CUSTOMER_EXTRA_REDUCERS ,
14
+
15
+ /**
16
+ * Provides additional reducers that run after the standard Daffodil customer reducers.
17
+ *
18
+ * ```ts
19
+ * providers: [
20
+ * ...daffCustomerProvideExtraReducers(
21
+ * myReducer1,
22
+ * myReducer2
23
+ * )
24
+ * ]
25
+ * ```
26
+ */
27
+ provider : daffCustomerProvideExtraReducers ,
28
+ } = createMultiInjectionToken < ActionReducer < DaffCustomerReducersState > > (
15
29
'DAFF_CUSTOMER_EXTRA_REDUCERS' ,
16
- {
17
- factory : ( ) => [ ] ,
18
- providedIn : 'any' ,
19
- } ,
30
+ { providedIn : 'any' } ,
20
31
) ;
21
-
22
- /**
23
- * Provides additional reducers that run after the standard Daffodil customer reducers.
24
- *
25
- * ```ts
26
- * providers: [
27
- * ...daffCustomerProvideExtraReducers(
28
- * myReducer1,
29
- * myReducer2
30
- * )
31
- * ]
32
- * ```
33
- */
34
- export function daffCustomerProvideExtraReducers (
35
- ...reducers : ActionReducer < DaffCustomerReducersState > [ ]
36
- ) : Provider [ ] {
37
- return reducers . map ( reducer => ( {
38
- provide : DAFF_CUSTOMER_EXTRA_REDUCERS ,
39
- useValue : reducer ,
40
- multi : true ,
41
- } ) ) ;
42
- }
Original file line number Diff line number Diff line change 1
- import {
2
- inject ,
3
- InjectionToken ,
4
- } from '@angular/core' ;
1
+ import { inject } from '@angular/core' ;
5
2
import {
6
3
ActionReducer ,
7
4
combineReducers ,
8
5
} from '@ngrx/store' ;
9
6
7
+ import { createSingleInjectionToken } from '@daffodil/core' ;
10
8
import { daffComposeReducers } from '@daffodil/core/state' ;
11
9
// these unused imports are a workaround
12
10
import { DaffCustomer } from '@daffodil/customer' ;
@@ -17,13 +15,16 @@ import { daffCustomerAddressEntitiesReducer } from '../address-entities/public_a
17
15
import { daffCustomerReducer } from '../customer/reducer' ;
18
16
import { DaffCustomerReducersState } from '../reducers.interface' ;
19
17
20
- /**
21
- * An internal token to hold the Daffodil customer reducers.
22
- * Includes the extra and standard reducers.
23
- *
24
- * @docs -private
25
- */
26
- export const DAFF_CUSTOMER_REDUCERS = new InjectionToken < ActionReducer < DaffCustomerReducersState > > (
18
+ export const {
19
+ /**
20
+ * An internal token to hold the Daffodil customer reducers.
21
+ * Includes the extra and standard reducers.
22
+ *
23
+ * @docs -private
24
+ */
25
+ token : DAFF_CUSTOMER_REDUCERS ,
26
+ provider : daffProvideCustomerReducers ,
27
+ } = createSingleInjectionToken < ActionReducer < DaffCustomerReducersState > > (
27
28
'DAFF_CUSTOMER_REDUCERS' ,
28
29
{
29
30
providedIn : 'any' ,
You can’t perform that action at this time.
0 commit comments