Skip to content

HortiView Events

HortiView Events are platform-level triggers that allow modules to “hook into” specific lifecycle moments or actions within the HortiView platform. When an event occurs—such as the platform finishing its initialization—the system can dynamically call an exposed component from a module to execute logic associated with that event.

This mechanism enables modules to respond to platform changes without requiring the full module UI to load. It is a key part of HortiView’s modular architecture, supporting lightweight, event-driven workflows and improving performance.

Events provide a structured way for modules to:

  • Execute background logic at critical points (e.g., after platform load)
  • Register additional functionality without bloating the main module
  • Implement mini-workflows or data synchronization tasks without rendering a full interface

By leveraging Module Federation’s dynamic loading capabilities, HortiView can call only the components or functions needed for an event, reducing resource usage and improving responsiveness. It also allows us the call a modules logic, without any user interaction.

Current Implementation - Function Components

HortiView currently supports two core events:

  • OnPlatformLoaded
  • OnBackOnline

Function Components

A Functions Component is an exposed component that allows you to define simple functions or methods for specific HortiView events. When an event occurs, the platform will invoke the corresponding function within this component, enabling you to execute event-driven logic without rendering a React component.

Implementation

All events handled via the Functions Component must be implemented as named exports within the component. The Functions Component itself must be exposed under the strict name ./Functions in your module federation configuration. For example:

1
2
3
4
5
6
7
{
    "name": "your_module_name",
    "filename": "yourModule.js",
    "exposes": {
        "./Functions": "./src/Template/events/Functions/HortiViewEvents
    }
}

Each event function should be exported with a dedicated name matching the event it handles. The platform will load the Functions Component and call the appropriate function at the relevant event time, passing the module context as needed. This approach allows your event logic to access other utilities or nested functions within your module.

import { BaseProps } from "@hortiview/modulebase";

export const onPlatformLoaded = (customProps: BaseProps) => {
    //basic  prefetching
    console.log('we just called a function via module federation when platform is ready', customProps);
}

export const onBackOnline = (customProps: BaseProps) => {
    //basic  prefetching
    console.log('we just called a function via module federation when platform is back online', customProps);
}