@sigi/react
Version:
React bindings for sigi framework
30 lines (25 loc) • 660 B
text/typescript
import { Effect, EffectModule, ImmerReducer, Module } from '@sigi/core'
import { Draft } from 'immer'
import { endWith, map, mergeMap, Observable, timer } from 'rxjs'
interface TipState {
tip: string
}
('TipModel')
export class TipModule extends EffectModule<TipState> {
defaultState = { tip: '' }
()
setTip(state: Draft<TipState>, tip: string) {
state.tip = tip
}
({ ssr: true })
getTip(payload$: Observable<void>) {
return payload$.pipe(
mergeMap(() =>
timer(1).pipe(
map(() => this.getActions().setTip('tip')),
endWith(this.terminate()),
),
),
)
}
}