MCPcopy Create free account
hub / github.com/LeetCode-OpenSource/ayanami / SSREffect

Function SSREffect

src/ssr/express.ts:46–70  ·  view source on GitHub ↗
(options?: SSREffectOptions<Payload>)

Source from the content-addressed store, hash-verified

44
45// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
46export 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}

Callers 2

CountModelClass · 0.90
TipModelClass · 0.90

Calls 2

isSSREnabledFunction · 0.90
addDecoratorFunction · 0.85

Tested by

no test coverage detected