(options?: SSREffectOptions<Payload>)
| 44 | |
| 45 | // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types |
| 46 | export function SSREffect<T, Payload>(options?: SSREffectOptions<Payload>) { |
| 47 | const { payloadGetter, skipFirstClientDispatch } = { |
| 48 | payloadGetter: undefined, |
| 49 | skipFirstClientDispatch: true, |
| 50 | ...options, |
| 51 | } |
| 52 | |
| 53 | return (target: T, method: string, descriptor: PropertyDescriptor) => { |
| 54 | addDecorator(target, method, payloadGetter) |
| 55 | if (!isSSREnabled() && skipFirstClientDispatch) { |
| 56 | const originalValue = descriptor.value |
| 57 | descriptor.value = function ( |
| 58 | this: any, |
| 59 | action$: Observable<Payload>, |
| 60 | state$?: Observable<any>, |
| 61 | ) { |
| 62 | if (Reflect.getMetadata(this.ssrLoadKey, this)) { |
| 63 | return originalValue.call(this, action$.pipe(skip(1)), state$) |
| 64 | } |
| 65 | return originalValue.call(this, action$, state$) |
| 66 | } |
| 67 | } |
| 68 | return Effect()(target, method, descriptor) |
| 69 | } |
| 70 | } |
no test coverage detected