Inline macro performance enhancing by sharing data

I have been developing a forge app for confluence with module inline Macro (UI Kit). due to the nature of the app, the user will create a lot of such macros in the same page.

Each macro do 3 requests in the fronend, is there anyway possible to share the response of these requests across all macros in the page, since they are not unique per-macro, but only per-page.

So optimally I only need to do 3 requests in total for each page visit regardless of how many macros are there.

Any one have an idea or a direction?

Seems like you could use app storage for that. You’d need to make requests to the storage, but not make external requests (if that’s what you want to save).

Hey AaronCollier,

I have seen these type of storages, they are external storages hosted by confluence and still will suffer from the same issue (http requests for each element).

but fundamentally i want the macros inside the page to somehow communicate to each other in the user end, something like event bridge: https://developer.atlassian.com/platform/forge/apis-reference/ui-api-bridge/events/

but this one is for Custom UI extensions and not for UI kits.

For future readers, I have found the solution with the use of backgroundScript: https://developer.atlassian.com/platform/forge/manifest-reference/modules/confluence-background-script

It provides a background script that allows modules in the same page to use as common channel.

each macro communicate with the background script it uses event-based type with emit and listen.

the docs above provides an example of that communication.

Best regards,
Abdelhamed

1 Like

Dear @Abdelhamed

are you willingly to share some more details of your solution? In particular: how do you feed the macros from the background script?

Thank you

Andreas

Dear Andreas,

I have updated my comment with more details, please check it out.

Best regards,
Abdelhamed