File tree 5 files changed +52
-57
lines changed
5 files changed +52
-57
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
3
import { DaffCartWithStoreCredit } from '@daffodil/cart-store-credit' ;
4
+ import { createSingleInjectionToken } from '@daffodil/core' ;
5
5
6
6
/**
7
7
* An injection token for the cart store credit driver.
8
8
*/
9
- export const DaffCartStoreCreditDriver = new InjectionToken < DaffCartStoreCreditDriverInterface > ( 'DaffCartStoreCreditDriver' ) ;
9
+ export const {
10
+ token : DaffCartStoreCreditDriver ,
11
+ provider : daffProvideCartStoreCreditDriver ,
12
+ } = createSingleInjectionToken < DaffCartStoreCreditDriverInterface > ( 'DaffCartStoreCreditDriver' ) ;
10
13
11
14
/**
12
15
* The cart store credit driver is responsible for loading carts.
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_CART_STORE_CREDIT_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_CART_STORE_CREDIT_ERROR_MATCHER ,
10
+ provider : daffProvideCartStoreCreditErrorMatcher ,
11
+ } = createSingleInjectionToken < typeof daffTransformErrorToStateError > (
10
12
'DAFF_CART_STORE_CREDIT_ERROR_MATCHER' ,
11
13
{ factory : ( ) => daffTransformErrorToStateError } ,
12
14
) ;
Original file line number Diff line number Diff line change 1
- export { DAFF_CART_STORE_CREDIT_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 { DaffCartStoreCreditReducersState } from '../reducers.interface' ;
8
6
9
- /**
10
- * A token to hold the injectable extra reducers.
11
- *
12
- * Prefer using {@link daffCartStoreCreditProvideExtraReducers}.
13
- */
14
- export const DAFF_CART_STORE_CREDIT_EXTRA_REDUCERS = new InjectionToken < ActionReducer < DaffCartStoreCreditReducersState > [ ] > (
7
+ export const {
8
+ /**
9
+ * A token to hold the injectable extra reducers.
10
+ *
11
+ * Prefer using {@link daffCartStoreCreditProvideExtraReducers}.
12
+ */
13
+ token : DAFF_CART_STORE_CREDIT_EXTRA_REDUCERS ,
14
+
15
+ /**
16
+ * Provides additional reducers that run after the standard Daffodil cart reducers.
17
+ *
18
+ * ```ts
19
+ * providers: [
20
+ * ...daffCartStoreCreditProvideExtraReducers(
21
+ * myReducer1,
22
+ * myReducer2
23
+ * )
24
+ * ]
25
+ * ```
26
+ */
27
+ provider : daffCartStoreCreditProvideExtraReducers ,
28
+ } = createMultiInjectionToken < ActionReducer < DaffCartStoreCreditReducersState > > (
15
29
'DAFF_CART_STORE_CREDIT_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 cart reducers.
24
- *
25
- * ```ts
26
- * providers: [
27
- * ...daffCartStoreCreditProvideExtraReducers(
28
- * myReducer1,
29
- * myReducer2
30
- * )
31
- * ]
32
- * ```
33
- */
34
- export function daffCartStoreCreditProvideExtraReducers (
35
- ...reducers : ActionReducer < DaffCartStoreCreditReducersState > [ ]
36
- ) : Provider [ ] {
37
- return reducers . map ( reducer => ( {
38
- provide : DAFF_CART_STORE_CREDIT_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
10
7
import { DaffCartWithStoreCredit } from '@daffodil/cart-store-credit' ;
8
+ import { createSingleInjectionToken } from '@daffodil/core' ;
11
9
import { daffComposeReducers } from '@daffodil/core/state' ;
12
10
// these unused imports are a workaround
13
11
14
12
import { DAFF_CART_STORE_CREDIT_EXTRA_REDUCERS } from './extra.token' ;
15
13
import { DaffCartStoreCreditReducersState } from '../reducers.interface' ;
16
14
import { daffCartStoreCreditReducer } from '../store-credit/public_api' ;
17
15
18
- /**
19
- * An internal token to hold the Daffodil cart reducers.
20
- * Includes the extra and standard reducers.
21
- *
22
- * @docs -private
23
- */
24
- export const DAFF_CART_STORE_CREDIT_REDUCERS = new InjectionToken < ActionReducer < DaffCartStoreCreditReducersState > > (
16
+ export const {
17
+ /**
18
+ * An internal token to hold the Daffodil cart reducers.
19
+ * Includes the extra and standard reducers.
20
+ *
21
+ * @docs -private
22
+ */
23
+ token : DAFF_CART_STORE_CREDIT_REDUCERS ,
24
+ provider : daffProvideCartStoreCreditReducers ,
25
+ } = createSingleInjectionToken < ActionReducer < DaffCartStoreCreditReducersState > > (
25
26
'DAFF_CART_STORE_CREDIT_REDUCERS' ,
26
27
{
27
28
providedIn : 'any' ,
You can’t perform that action at this time.
0 commit comments