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

Avatar

Avatar

mchag

Avatar

mchag

mchag

23-07-2018

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

Replies

Highlighted

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831
Arun_Patidar
MVP

23-07-2018

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

Highlighted

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K
smacdonald2008

23-07-2018

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.

Highlighted

Avatar

Avatar

mchag

Avatar

mchag

mchag

23-07-2018

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

Highlighted

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831
Arun_Patidar
MVP

23-07-2018

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  

Highlighted

Avatar

Avatar

mchag

Avatar

mchag

mchag

06-08-2018

Thanks Arun for your suggestions