products: [] as Product[]}), withComputed((store) => ({ cartProductsCount: computed(() => store.products().length), totalAmount: computed(() => { /* ... */ }), })), withMethods((store, checkoutService = inject(CheckoutService)) => ({ loadAll: rxMethod<void>( exhaustMap(() => checkoutService.getCartProducts().pipe( tapResponse({ next: (products) => patchState(store, { products }), }), ), ), ), // ... })), withHooks({ onInit(store) { store.loadAll(); }, }), ); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 withState<CheckoutState>({ products: [] as Product[]}), export const CheckoutStore = signalStore( 1 { providedIn: 'root' }, 2 3 withComputed((store) => ({ 4 cartProductsCount: computed(() => store.products().length), 5 totalAmount: computed(() => { /* ... */ }), 6 })), 7 withMethods((store, checkoutService = inject(CheckoutService)) => ({ 8 loadAll: rxMethod<void>( 9 exhaustMap(() => 10 checkoutService.getCartProducts().pipe( 11 tapResponse({ 12 next: (products) => patchState(store, { products }), 13 }), 14 ), 15 ), 16 ), 17 // ... 18 })), 19 withHooks({ 20 onInit(store) { 21 store.loadAll(); 22 }, 23 }), 24 ); 25 withComputed((store) => ({ cartProductsCount: computed(() => store.products().length), totalAmount: computed(() => { /* ... */ }), })), export const CheckoutStore = signalStore( 1 { providedIn: 'root' }, 2 withState<CheckoutState>({ products: [] as Product[]}), 3 4 5 6 7 withMethods((store, checkoutService = inject(CheckoutService)) => ({ 8 loadAll: rxMethod<void>( 9 exhaustMap(() => 10 checkoutService.getCartProducts().pipe( 11 tapResponse({ 12 next: (products) => patchState(store, { products }), 13 }), 14 ), 15 ), 16 ), 17 // ... 18 })), 19 withHooks({ 20 onInit(store) { 21 store.loadAll(); 22 }, 23 }), 24 ); 25 withMethods((store, checkoutService = inject(CheckoutService)) => ({ loadAll: rxMethod<void>( exhaustMap(() => checkoutService.getCartProducts().pipe( tapResponse({ next: (products) => patchState(store, { products }), }), ), ), ), // ... })), export const CheckoutStore = signalStore( 1 { providedIn: 'root' }, 2 withState<CheckoutState>({ products: [] as Product[]}), 3 withComputed((store) => ({ 4 cartProductsCount: computed(() => store.products().length), 5 totalAmount: computed(() => { /* ... */ }), 6 })), 7 8 9 10 11 12 13 14 15 16 17 18 19 withHooks({ 20 onInit(store) { 21 store.loadAll(); 22 }, 23 }), 24 ); 25 withHooks({ onInit(store) { store.loadAll(); }, }), export const CheckoutStore = signalStore( 1 { providedIn: 'root' }, 2 withState<CheckoutState>({ products: [] as Product[]}), 3 withComputed((store) => ({ 4 cartProductsCount: computed(() => store.products().length), 5 totalAmount: computed(() => { /* ... */ }), 6 })), 7 withMethods((store, checkoutService = inject(CheckoutService)) => ({ 8 loadAll: rxMethod<void>( 9 exhaustMap(() => 10 checkoutService.getCartProducts().pipe( 11 tapResponse({ 12 next: (products) => patchState(store, { products }), 13 }), 14 ), 15 ), 16 ), 17 // ... 18 })), 19 20 21 22 23 24 ); 25