How to run client action when all aggregates in the screen are fetched in Reactive

How do i run a client action after ALL the aggregates in the screen are fetched in Reactive Web?


Hi Ronald,

You can use one "On After Fatch" event

It trigger when data return from aggregate .

In aggregates when you fatch data there is one special feture when you want run this aggreagte 

Like Fatch-" At Start " or "Only on demand"


Regards

Rahul Sahu

Rahul Sahu wrote:

Hi Ronald,

You can use one "On After Fatch" event

It trigger when data return from aggregate .

In aggregates when you fatch data there is one special feture when you want run this aggreagte 

Like Fatch-" At Start " or "Only on demand"


Regards

Rahul Sahu

the problem is i have multiple aggregates. The On After Fetch Event works on individual aggregates. i want to run a server action once all the aggregates are fetched.


Solution

Hi Ronald,

Yes i have understnad your problems,

You need to put extra logic for that, you can do one this. 

set only one aggregate "At Start" and set other aggregate as "Only On Demand "

and use on after fatch for "At Start" aggregate and refresh all aggregates of "only on demand ". after all aggregate refresh after that run your logic.


Hope this will help you.

Regards

Rahul Sahu

Solution

Rahul Sahu wrote:

Hi Ronald,

Yes i have understnad your problems,

You need to put extra logic for that, you can do one this. 

set only one aggregate "At Start" and set other aggregate as "Only On Demand "

and use on after fatch for "At Start" aggregate and refresh all aggregates of "only on demand ". after all aggregate refresh after that run your logic.


Hope this will help you.

Regards

Rahul Sahu


Thanks :)

Welcome Ronald, Glad to help you.


Regards

Rahul Sahu

I do this differently (I also have this usecase). All my aggregates don't depend on each other but I need all of them completed before I can start an other data retrieval.

I do the following;

  1. Add a "IsAllDataLoaded" boolean to the screen/block
  2. I create a client function (if needed) to perform the steps after all the data is available
  3. In the OnAfterFetch of all aggregates I will check if all aggregates are loaded with a
    IsAllDataLoaded = data.IsDataFetched 
  4. If this boolean becomes True then I will perform the next step, either loading new data or performing some logic.


This will how the OnAfterFetch looks like;


This is how the screen looks like;


I attached a demo sample for you to look into.


@Vicent Koning, nice clean implementation.