-
{{
- counterData?.data?.count || 0
- }}
+
{{ data?.count || 0 }}
@@ -29,23 +27,11 @@ import { useDecrementCountByIdMutation, useIncrementCountByIdMutation } from '@a
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CounterRowComponent {
- @Input() counterData?: {
- originalArgs?: string;
- isFetching: boolean;
- isUninitialized: boolean;
- data?: { count: number };
- };
+ @Input() originalArgs?: string;
+ @Input() data?: { count: number };
+ @Input() isFetching: boolean = false;
+ @Input() isUninitialized: boolean = true;
increment = useIncrementCountByIdMutation();
decrement = useDecrementCountByIdMutation();
-
- constructor() {}
-
- incrementCounter(): void {
- this.increment.dispatch({ id: this.counterData?.originalArgs ?? '', amount: 1 });
- }
-
- decrementCounter(): void {
- this.decrement.dispatch({ id: this.counterData?.originalArgs ?? '', amount: 1 });
- }
}
diff --git a/src/app/features/lazy/lazy-counter/lazy.component.ts b/src/app/features/lazy/lazy-counter/lazy.component.ts
index dbe5368..37efc5f 100644
--- a/src/app/features/lazy/lazy-counter/lazy.component.ts
+++ b/src/app/features/lazy/lazy-counter/lazy.component.ts
@@ -13,12 +13,8 @@ const { getCountById } = counterApiEndpoints;
Start Lazy Counter
@@ -37,13 +38,32 @@ const { getCountById } = counterApiEndpoints;
Duplicate state (Share state, subscription & selectFromResult)
Use in same component (not subscripted by self)
-
+
Select from state (Share state & subscription, another selectFromResult)
Use in same component or child components (not subscripted by self)
-
+
+
+
+ Select from state parent signal
+
@@ -51,7 +71,12 @@ const { getCountById } = counterApiEndpoints;
Related Query (Share cache data / another subscription & selectFromResult or Options)
Use anywhere (subscripted by self), skip subscribe with uninitialized value
-
+
`,
@@ -73,8 +98,7 @@ export class LazyComponent {
constructor(private formBuilder: UntypedFormBuilder) {}
async startCounterById({ id, preferCacheValue }: { id: string; preferCacheValue: boolean }): Promise