( paramsOrTarget: MutationActionParams<T> | M, key?: string | symbol, descriptor?: TypedPropertyDescriptor<(...args: any[]) => Promise<Partial<K> | undefined>> )
| 91 | * @constructor |
| 92 | */ |
| 93 | export function MutationAction<T, K, M extends K>( |
| 94 | paramsOrTarget: MutationActionParams<T> | M, |
| 95 | key?: string | symbol, |
| 96 | descriptor?: TypedPropertyDescriptor<(...args: any[]) => Promise<Partial<K> | undefined>> |
| 97 | ): |
| 98 | | (( |
| 99 | target: T, |
| 100 | key: string | symbol, |
| 101 | descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise<Partial<T> | undefined>> |
| 102 | ) => void) |
| 103 | | void { |
| 104 | if (!key && !descriptor) { |
| 105 | /* |
| 106 | * This is the case when `paramsOrTarget` is params. |
| 107 | * i.e. when used as - |
| 108 | * <pre> |
| 109 | @MutationAction({mutate: ['incrCount']}) |
| 110 | async getCountDelta() { |
| 111 | return {incrCount: 5} |
| 112 | } |
| 113 | * </pre> |
| 114 | */ |
| 115 | return mutationActionDecoratorFactory(paramsOrTarget as MutationActionParams<T>) |
| 116 | } else { |
| 117 | /* |
| 118 | * This is the case when `paramsOrTarget` is target. |
| 119 | * i.e. when used as - |
| 120 | * <pre> |
| 121 | @MutationAction |
| 122 | async getCountDelta() { |
| 123 | return {incrCount: 5} |
| 124 | } |
| 125 | * </pre> |
| 126 | */ |
| 127 | mutationActionDecoratorFactory({} as MutationActionParams<K>)( |
| 128 | paramsOrTarget as K, |
| 129 | key!, |
| 130 | descriptor! |
| 131 | ) |
| 132 | } |
| 133 | } |
no test coverage detected