-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat) POC - Offline ready jobs #823
base: main
Are you sure you want to change the base?
(feat) POC - Offline ready jobs #823
Conversation
@icrc-jofrancisco So I've thought about this for a bit and I think the thing to do here is instead of having a defined module callback, let's do this with a custom event. That way we can push the offline handling logic mostly down into apps themselves. Specifically, what I'm thinking is that we dispatch an event from window.dispatchEvent(
new CustomEvent(
`openmrs:offline-${mode === "on" ? "enabled" : "disabled"}`,
getCurrentOfflineMode()
)
); Then in each apps window.addEventListener("openmrs:offline-enabled", ({ detail: offlineMode } : { detail: OfflineModeResult}) => setupOffline(offlineMode));
const offlineMode = getCurrentOfflineMode();
if (offlineMode.active) {
setupOffline(offlineMode);
} I like this because it means we don't need to figure out whether an app needs to be informed that offline mode was re-enabled or not, i.e., we can let each app determine how it responds to that event. There's also much less dynamic dispatch code that way. Make sense? |
@icrc-jofrancisco @ibacher What should we do about this PR? |
8f994a6
to
9cee659
Compare
Requirements
For changes to apps
If applicable
Summary
IN PROGRESS
This Pull request solves a need to improve the experience when the user is offline.
It is intended to create a function for all microfront-ends (if the function exists) that will be executed when it is triggered in the
esm-offline-tools-app.
The idea is that this function contains specific logic for each app to fetch data from the server (or specific offline logic) and that it caches these results, allowing all resources to be loaded dynamically.
Main idea implemented/to be implemented so far:
OfflineReady
functions are dynamically loaded into thewindow.installedModules
variable, accessible by all apps.Offline functionality is managed through a toggle in the user menu, facilitated by the
esm-offline-tools-app
. Activating the toggle prompts a modal with spinner, tracking the execution progress of offlineReady functions across installed apps.Upon successful completion, a success popup is displayed. In case of failure. The user can trigger function refresh by clicking the provided button.
Note: offline preparation is triggered using the event
openmrs:offline-enabled
. This event signals subscribed apps to execute the necessary functions.Screenshots
Related Issue
Other
CC: @ibacher