if we invoke else service method suck as this.getActions() inside the effectActions[actionName] function in sync way, it will cause an error:
InternalError: "too much recursion"
the effect can be:
@Effect()
fetchInfo(url$: Observable<string>):Observable<EffectAction> {
return url$.pipe(
switchMap(url => from(client.get(url))),
mergeMap(data => of(this.getActions().setData(data), this.getActions().setLoading(false))),
startWith(this.getActions().setLoading(true)),
)
}
the effect init function is :
|
const effect$: Observable<EffectAction> = effectActions[actionName](payload$, state$) |
because the startWith is sync, so this.getActions() will request the ikari instance, but the ikari instance is not fully constructed at that time. so it will invoke the create function again and agian...
if we invoke else service method suck as
this.getActions()inside theeffectActions[actionName]function in sync way, it will cause an error:the effect can be:
the effect init function is :
ayanami/src/core/ikari.ts
Line 196 in b7b644b
because the
startWithis sync, sothis.getActions()will request theikariinstance, but the ikari instance is not fully constructed at that time. so it will invoke the create function again and agian...