Skip to content

Commit 6eb2c04

Browse files
committed
feat(decorators): add types to Reducer and Effect
1 parent 5865c49 commit 6eb2c04

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/core/decorators/index.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1-
import { defineActionSymbols, effectSymbols, reducerSymbols } from '../symbols'
1+
import { Observable } from 'rxjs'
22

3+
import { defineActionSymbols, effectSymbols, reducerSymbols } from '../symbols'
4+
import { EffectAction } from '../types'
35
import { createActionDecorator } from './action-related'
46

57
export * from './action-related'
68

7-
export const Reducer = createActionDecorator(reducerSymbols)
8-
export const Effect = createActionDecorator(effectSymbols)
9+
interface DecoratorReturnType<V> {
10+
(target: any, propertyKey: string, descriptor: { value?: V; get?(): V }): void
11+
}
12+
13+
export const Reducer: <S = any>() => DecoratorReturnType<
14+
(state: S, params?: any) => S
15+
> = createActionDecorator(reducerSymbols)
16+
17+
export const Effect: <A = any, S = any>() => DecoratorReturnType<
18+
(action: Observable<A>, state$: Observable<S>) => Observable<EffectAction>
19+
> = createActionDecorator(effectSymbols)
20+
921
export const DefineAction = createActionDecorator(defineActionSymbols)

0 commit comments

Comments
 (0)