@@ -17,11 +17,11 @@ import {
1717 DataStateClass ,
1818 DispatchedResult ,
1919 ImmutableDataRepository ,
20+ type MappedStore ,
2021 NgxsDataOperation ,
2122 NgxsRepositoryMeta ,
2223 RepositoryActionOptions ,
2324} from '@angular-ru/ngxs/typings' ;
24- import { MappedStore } from '@ngxs/store/src/internal/internals' ;
2525import { isObservable , Observable , of } from 'rxjs' ;
2626import { map } from 'rxjs/operators' ;
2727
@@ -48,11 +48,12 @@ export function DataAction(options: RepositoryActionOptions = {}): MethodDecorat
4848 NgxsDataFactory . getRepositoryByInstance ( instance ) ;
4949 const operations : PlainObjectOf < NgxsDataOperation > = repository . operations ! ;
5050 let operation : NgxsDataOperation | undefined = operations [ key ] ;
51+ const operationNotSet = isNil ( operation ) ;
5152 const stateMeta : any = repository . stateMeta ;
5253 const registry : MethodArgsRegistry | undefined =
5354 getMethodArgsRegistry ( originalMethod ) ;
5455
55- if ( isNil ( operation ) ) {
56+ if ( operationNotSet ) {
5657 // Note: late init operation when first invoke action method
5758 const argumentsNames : string [ ] = $args ( originalMethod ) ;
5859 const type : string = actionNameCreator ( {
@@ -67,15 +68,13 @@ export function DataAction(options: RepositoryActionOptions = {}): MethodDecorat
6768 options : { cancelUncompleted : config . cancelUncompleted ?? false } ,
6869 } ;
6970
70- if ( isNotNil ( operation ) ) {
71- stateMeta . actions [ operation . type ] = [
72- {
73- type : operation . type ,
74- options : operation . options ,
75- fn : operation . type ,
76- } ,
77- ] ;
78- }
71+ stateMeta . actions [ operation . type ] = [
72+ {
73+ type : operation . type ,
74+ options : operation . options ,
75+ fn : operation . type ,
76+ } ,
77+ ] ;
7978 }
8079
8180 const mapped : MappedStore = NgxsDataFactory . ensureMappedState ( stateMeta ) ! ;
@@ -98,8 +97,19 @@ export function DataAction(options: RepositoryActionOptions = {}): MethodDecorat
9897 : result ;
9998 } ;
10099
100+ if ( operationNotSet ) {
101+ const factory = NgxsDataInjector . factory ! ;
102+
103+ factory . hydrateActionMetasMap ( {
104+ ...mapped ,
105+ actions : {
106+ [ operation . type ] : mapped . actions [ operation . type ] ,
107+ } ,
108+ } ) ;
109+ }
110+
101111 const event : ActionEvent = NgxsDataFactory . createAction (
102- operation ,
112+ operation . type ,
103113 args ,
104114 registry ,
105115 ) ;
0 commit comments