Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How to use RxJS to dynamically pass data between two AEM components

Avatar

Level 2

Hi,

We have requirement where we have two components

1.Search Form (which will have the Search Form and Google Map)

2.Search Results component

"Search Form" and "Search Results"  are being developed as two different component because team wanted to re use the "Search Form"

The Ajax call to service goes out from Search From component, team has proposed the RxJS solution to dynamically communicate data between Search From and Search Results component. So, whenever there is new search RxJS has to dynamically update the Search Results component.

If any body has developed this kind of approach, can you advice on this.

Thanks,

Madhu

5 Replies

Avatar

Community Advisor

Hi Madhu,

Why don't you submit form instead making Ajax call on search button click as a Post request and action page would be your search table/result page. This way you can communicate between components.

If you have both search and search result component on both pages, then you can put a condition of search result component to identify initialled and search load.

Thanks

Arun



Arun Patidar

Avatar

Level 10

Arun is correct - Ajax is standard way - with a Sling Servlet - to do this type of use case.  I have never seen any RxJS solution  example with AEM.

Avatar

Level 2

Hi Arun,

Thanks for your reply,

There is only one page i.e "search page" where both components present, so on click of  "Search" button user stays on same  page but we would required to refresh always search results component , that's why we have to do Ajax call rather form submission.

So we have to add RxJS observer to trigger the change and refresh the search results component.

Thanks,

Madhu

Avatar

Community Advisor

Then you can do a normal Ajax call to service and update the search result section of content of search.

There is no need to established special relationship between components.

you can specify a unique id to result component wrapper and based on that you can update the content.

Tryit Editor v3.5  



Arun Patidar