Open PhilippMDoerner opened 1 year ago
Changing approaches, how about trying to go for using signal stores. Maybe that can take away some of the boilerplate
Changing approach, signal store features are a pain to work with type-wise. Particularly for more complex features such as request caching.Migrating to an approach of services with subjects that you create via a factory.
Service approach works, can migrate that to a somewhat cleaner version: Have a Subject that triggers http requests and forwards args from the function call like this:
class MyService {
private load$ = new Subject<void>();
readonly data$ = this.load$.pipe(
switchMap(() => this.http.get(...)),
shareReplay(1),
);
load() {
this.load$.next();
}
}
Use the Effectsfactory for this to avoid the boilerplate-y bits.
effects:
resolvers:
actions:
service-calls: