What events can cause all store states to be loaded when the page is altered?

I am currently utilizing ngrx/store, ngrx/effects, and ngrx/router.

The implementation of my effects is structured as follows:

 @Effect() loadOneProduct$ = this.updates$
    .whenAction(LOAD_ONE_PRODUCT)
    .switchMap(() => this.productService.loadOneProduct())
    .map(oneProduct => ({ type: LOAD_ONE_PRODUCT_SUCCESS, payload: oneProduct }));

 @Effect() loadOneWorker$ = this.updates$
    .whenAction(LOAD_ONE_WORKER)
    .switchMap(() => this.workerService.loadOneWorker())
    .map(oneWorker => ({ type: LOAD_ONE_WORKER_SUCCESS, payload: oneWorker }));

Initially, the state of the store is defined as shown below:

{
  company: { name: 'Google' },
  products: {},
  workers: {}
}

1) Upon executing

this.store.dispatch({ type: LOAD_ONE_PRODUCT });
, the state transforms into:

{
  company: { name: 'Google' },
  products: {
    oneProduct: {
      label: 'Phone'
    } 
  },
  workers: {}
}

2) After triggering

this.store.dispatch({ type: LOAD_ONE_WORKER });
, it changes to:

{
  company: { name: 'Google' },
  products: {
    oneProduct: {
      label: 'Phone'
    } 
  },
  workers: {
    oneWorker: {
      name: 'Tom'
    } 
  },
}

3) Subsequently, upon navigating to another PAGE,

{{store|async|json}}

ngOnInit()
{
   this.subscription = this.store
      .select(x => x.products && x.products.oneProduct)
      .subscribe(oneProduct => {
        // "undefined" value received at this point. Expecting to fetch the latest value from the store.
        console.log(oneProduct);
      });

      // All discrepancies are rectified by dispatching any action
      // I introduced an action named TEST, which lacks a reducer, indicating no alteration in store state, yet it functions as expected
}

As per the current output of {{store|async|json}}:

{
  company: { name: 'Google' },
  products: {},
  workers: {}
}

All states revert back to their original form. Both products and workers vanish. (NOTE: The disappearance of workers also occurs.)

(Nevertheless, the state tree in Chrome Extension Redux Tools consistently appears correct.)

Even after including a button and manually invoking ChangeDetectorRef with this._cdRef.detectChanges();, {{store|async|json}} continues to display the initial state. (Hence, seemingly not zone-related)

However, following the dispatch of certain actions afterwards, both products and workers resurface in the state. Subsequently, {{store|async|json}} exhibits the correct information.

Since the state tree always displays accurately in Chrome Extension Redux Tools, it suggests that the loading process may be flawed. My query is: what can be done to trigger the retrieval of all store states when navigating between pages? Thank you

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I use Angular 7 to create a background image for a View made up of multiple components?

Here is the HTML code that I am working with: <app-navbar></app-navbar> <router-outlet></router-outlet> My goal is to have an image set as the background for the home view, which consists of two components: navbarComponent and hom ...

Convert a nested JSON array into TypeScript class objects

Within the database exist two distinct entities: 'person' and 'name'. These entities share a many-to-many relationship with the properties 'from' and 'to'. Person PersonName Name -- ...

Creating Typescript type definitions for any object properties

Struggling to find the correct TS syntax with Typescript 3.7.3. I have a random object, for example: var obj = { one: ..., two: ... three: ... }; I want to create a type that includes all keys from that object, like this: type ObjKeys = &ap ...

Encountering a problem with Angular 11 SSR after compilation, where the production build is causing issues and no content is being displayed in

{ "$schema":"./node_modules/@angular/cli/lib/config/schema.json", "version":1, "newProjectRoot":"projects", "projects":{ "new-asasa":{ "projectType": ...

Creating a dynamic array in an Angular 2 service for real-time changes monitoring by a component

I am facing an issue where my NotificationsBellComponent is not receiving changes to the array in the service even though the _LocalStorageService is returning data correctly. Q) How can I ensure that my component receives updates when the service collect ...

Toggle switch with active state

I'm currently using Ionic 2 alongside Angular 2 beta 11. Is there a way to turn off the toggle switch? The Ionic documentation suggests using the checked attribute, but I've tried that and also attempted ng-checked with no luck. Any advice on t ...

Arrange a collection of objects by two criteria: the end time, followed by the status in accordance with the specified array order if the end times are equal

Is this the best method to arrange data by using infinity? I gave it a try but it doesn't quite meet my requirements. data = [{ "status": "Accepted", "endTime": "" }, { "status": "New", ...

Angular 4: Automatically dismiss modal once form submission process is complete

My Bootstrap 4 modal closes properly when I press the close button. However, I want the modal to close after submitting the create button in the form. I am using Angular 4. <div class="modal fade" id="createLabel" tabindex="-1" role="dialog" aria-label ...

Utilize data binding in Typescript to easily link variables between a service and controller for seamless utilization

Is there a way to overcome the issue of value assignment not binding data in this scenario? For example, using this.arrayVal = someService.arrayVal does not work as intended. The objective is to simplify the assignment in both HTML and controller by using ...

How can we leverage Shared and Core modules alongside Feature modules in Angular development?

When developing my Angular application, I have adopted a specific architecture approach and included a shared.module.ts file in the shared folder. While leveraging lazy-loading in my app, I find myself puzzled about the necessary imports, declarations, and ...

Creating or deleting multiple batches of entries in Firebase Realtime Database

I am currently utilizing Firebase real time database in the following way: createSoldLead(soldLead: SoldLeadModel): void { const soldLeadsReference = this.angularFireDatabase.list<SoldLeadModel>( `groups/${this.groupId}/soldLeads` ); ...

Deactivating PrimeNG checkbox

I am currently facing an issue with disabling a PrimeNG checkbox under certain conditions by setting the disabled property to true. However, whenever I click on the disabled checkbox, it refreshes the page and redirects me to the rootpage /#. To troublesh ...

Encountered an issue with formControlName being undefined during the render process in Angular 2

I encountered an issue while implementing Reactive form validation following the official Angular documentation. The error message "username not defined" is causing trouble in my project. Here's the detailed error: Error: Uncaught (in promise): Error: ...

Looking for Protractor CSS functionalities nodes

I tried the code below but am having trouble locating the "Login" text using Protractor: <div _ngcontent-c2="" class="align-center"> <img _ngcontent-c2="" alt="Autoprax" class="ap-logo" src="/images/apLogoSmall.svg" style="width: 100%"> ...

Filter array to only include the most recent items with unique names (javascript)

I'm trying to retrieve the most recent result for each unique name using javascript. Is there a straightforward way to accomplish this in javascript? This question was inspired by a similar SQL post found here: Get Latest Rates For Each Distinct Rate ...

Typescript enhances Solid JS by using the "as" prop and the "component" prop

Hey there, I've been experimenting with solid-js lately and I'm facing a challenge integrating it with typescript. My objective is to make my styling more modular by incorporating it within my components. type RelevantTags = Exclude<keyof ...

Angular 5 is throwing an error of TypeError: i28.ɵd is not a constructor

When I run the angular application in AOT mode using ng serve --aot, I encounter an error. It's important to note that there are no errors when building the application in AOT mode, but this error occurs in the browser when I access the application UR ...

"Exploring the Power of Angular 2 with Route Resolving

Currently, I am diving into the world of Angular and it's all quite new to me. I have a challenge where I need to display data in a view fetched from the server asynchronously. To tackle this, I attempted to use resolves to ensure the data is retrieve ...

Using query parameters in Angular to interact with APIs

One scenario involves a child component passing form field data to a parent component after a button press. The challenge arises when needing to pass these fields as query parameters to an API endpoint API GET /valuation/, where approximately 20 optional p ...

Issue with merging JSON in Angular using RxJS

Seeking assistance with combining two JSON objects in an Angular application. JSON Object 1: { "level1": { "level2": { "level31": "Text 1", "level32": "Text 2", "leve ...