ngrx/component-store this.select observable problem with suspenseTpl #4009
-
Hi! is it possible that the selector observable this.select(({ ...}) => ...); of ngrx/component-store could not work with ngrxLet directive with the suspenseTpl? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Suspense template from
State observables ( |
Beta Was this translation helpful? Give feedback.
-
Oh thanks for the suggestioni marko!!!!
Inviato da Outlook per Android<https://aka.ms/AAb9ysg>
…________________________________
From: Marko Stanimirović ***@***.***>
Sent: Friday, August 18, 2023 6:11:03 PM
To: ngrx/platform ***@***.***>
Cc: Mattia Malandrone ***@***.***>; Mention ***@***.***>
Subject: Re: [ngrx/platform] ngrx/component-store this.select observable problem with suspenseTpl (Discussion #4009)
**ATTENZIONE**: Questo messaggio proviene da un ACCOUNT ESTERNO, presta attenzione ad eventuali link o allegati al suo interno.
Btw, it's also possible to pass a dictionary of observables directly to the *ngrxLet directive:
@component({
standalone: true,
imports: [LetDirective],
template: `
<ng-container *ngrxLet="{ isLoading: isLoading$, users: users$ } as vm">
<p *ngIf="vm.isLoading; else userList">Loading...</p>
<ng-template #userList>
<!-- ... -->
</ng-template>
</ng-container>
`,
providers: [UsersStore],
/* ... */
})
export class UsersComponent {
private readonly store = inject(UsersStore);
readonly users$ = this.store.users$;
readonly isLoading$ = this.store.isLoading$;
}
—
Reply to this email directly, view it on GitHub<#4009 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACMXIG4E3HC2PB5TLRPJ4T3XV6HZPANCNFSM6AAAAAA3STXV6Y>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Hi @MattiaMalandrone,
Suspense template from
ngrxLet
can be used with observables that don't emit the first value synchronously (such asHttpClient.get
result) to display the loading template until the observable emits the first value. In the case of ComponentStore whose state is initialized eagerly (via constructor), all observables created bythis.select((s) => s.prop)
will emit the first value (initial state) immediately, so suspense template will be never shown.