1
1
import { Injectable , inject } from "@angular/core" ;
2
2
import { rxMethod } from "@ngrx/signals/rxjs-interop" ;
3
3
import { Action , ActionCreator } from "@ngrx/store" ;
4
- import { map , pipe , tap } from "rxjs" ;
4
+ import { pipe , tap } from "rxjs" ;
5
+ import { dispatchActionToReduxDevtools } from "../redux-devtools" ;
5
6
import { MapperTypes } from "./model" ;
6
7
import { isUnsubscribable } from "./util" ;
7
8
@@ -15,7 +16,7 @@ import { isUnsubscribable } from "./util";
15
16
export class SignalReduxStore {
16
17
private mapperDict : Record < string , {
17
18
storeMethod : ( ...args : unknown [ ] ) => unknown ,
18
- resultMethod ?: ( ...args : unknown [ ] ) => unknown
19
+ resultMethod ?: ( ...args : unknown [ ] ) => unknown ,
19
20
} > = { } ;
20
21
21
22
dispatch = rxMethod < Action > ( pipe (
@@ -26,14 +27,19 @@ export class SignalReduxStore {
26
27
isUnsubscribable ( callbacks . storeMethod ) &&
27
28
callbacks . resultMethod
28
29
) {
29
- return callbacks . storeMethod ( action , callbacks . resultMethod ) as any ;
30
+ return callbacks . storeMethod ( action , ( a : Action ) => {
31
+ const resultAction = callbacks . resultMethod ?.( a ) as Action ;
32
+ this . dispatch ( resultAction ) ;
33
+ } ) ;
30
34
}
31
35
32
36
return callbacks ?. storeMethod ( action ) ;
33
37
}
34
38
35
- return action ;
36
- } )
39
+ return ;
40
+ } ) ,
41
+ //TODO: Refactor to DI token with optional callback
42
+ tap ( action => dispatchActionToReduxDevtools ( action ) )
37
43
) ) ;
38
44
39
45
connectFeatureStore ( mappers : MapperTypes < ActionCreator < any , any > [ ] > [ ] ) : void {
0 commit comments