ConstRegisters a listener for a GeoLeaf event.
The listener is called every time the event fires until it is removed — by the
function this call returns, or by off() with the same handler.
Event name (see module docs for full reference).
Callback receiving the CustomEvent with typed detail.
A function that removes this listener. It is off(event, handler) bound to
this subscription: calling it twice is harmless, and since the DOM registers one
listener per handler reference, it also removes an identical earlier on(). Without a
document (SSR), nothing is registered and the function does nothing.
Removes a previously registered listener.
The exact same handler reference must be passed.
Event name.
The handler reference originally passed to on().
// With off(), the handler must be NAMED — an anonymous one is removed through the
// function on() returns.
const handlePoiPanel = (e) => {
console.log(e.detail.poiId);
};
GeoLeaf.Events.on("geoleaf:poi:panel:open", handlePoiPanel);
// Plus tard :
GeoLeaf.Events.off("geoleaf:poi:panel:open", handlePoiPanel);
Registers a listener that fires once then automatically removes itself.
Uses the native {once: true} option — no wrapper function needed.
Event name.
Callback called at most once.
A function that cancels the listener if it has not fired yet — the teardown of
a component unmounted before the event arrives. Calling it after the listener fired is
harmless. Without a document (SSR), the function does nothing.
Public GeoLeaf Events API. Exposed as
GeoLeaf.Events(canonical) andGeoLeaf.events(legacy alias).