LogoRobo.js
Framework

HMR

Interface: HMR

HMR API interface.

Properties

PropertyModifierTypeDescription
enabledreadonlybooleanWhether HMR is currently enabled. Returns true only when running robo dev --hmr.

Methods

module()

module(metaUrl): HotModule

Get the HMR instance for a module. Call this at the top level of your module with import.meta.url.

When a module is reloaded, any previously registered dispose callbacks are executed before the new module instance registers its own.

Parameters

ParameterTypeDescription
metaUrlstringThe module URL from import.meta.url

Returns

HotModule

A HotModule instance for registering cleanup callbacks


subscribe()

subscribe(callback, options?): HmrSubscription

Subscribe to HMR events. Callbacks are invoked after handlers are reloaded in the portal.

Parameters

ParameterTypeDescription
callbackHmrCallbackFunction to call when HMR events occur
options?HmrSubscribeOptionsOptional filters for events

Returns

HmrSubscription

Subscription handle with unsubscribe method

Example

import { hmr } from 'robo.js/hmr'

const sub = hmr.subscribe((ctx) => {
  console.log('Routes reloaded:', ctx.routes)
}, {
  namespaces: ['server'],
  routes: ['api']
})

// Later: sub.unsubscribe()

On this page