@equinor/fusion-framework-module-event

中文文档
6.1.4发布于 2026/11/12ISCTypeScriptES Module近 30 天下载 1.2万

Fusion module for events

原始使用文档
文档目录8 节
  1. Who should use this
  2. Documentation
  3. Quick start
  4. Install
  5. Listen to an event
  6. Dispatch an event
  7. API overview
  8. Subpaths

@equinor/fusion-framework-module-event

Async event dispatching module for the Fusion Framework. Enables type-safe communication between framework modules (siblings) and across parent/child instances through an event system modeled after the native DOM EventTarget, but with async dispatch so cancelable events can be properly awaited.

Important: When dispatching a cancelable event you must await the dispatchEvent call. Firing without await means preventDefault() calls from listeners will not be respected.

Who should use this

  • Module authors that need to emit lifecycle or domain events other modules can react to.
  • Application developers that want to intercept, log, or cancel events flowing through the framework.
  • Library consumers that subscribe to event streams for analytics, debugging, or cross-cutting concerns.

Documentation

TopicDescription
ConfigurationonDispatch/onBubble hooks and registering custom event types via FrameworkEventMap
Observable Patternsevent$, filterEvent, and the ./operators subpath
LifecycleDispatch sequence, cancelable events, and bubbling
TestingwaitForEvent, watchEvents, and using a bespoke ModulesConfigurator in tests

Quick start

Install

pnpm add @equinor/fusion-framework-module-event

The event module is included by default when initializing the Fusion Framework, so explicit installation is only needed when using it standalone.

Listen to an event

const teardown = modules.event.addEventListener('onModulesLoaded', (event) => {
  console.log('All modules loaded:', event.detail);
});

// remove the listener when no longer needed
teardown();

Dispatch an event

const event = await modules.event.dispatchEvent('myEvent', {
  detail: { id: 42 },
  cancelable: true,
});

if (!event.canceled) {
  performAction();
}

API overview

ExportKindPurpose
FrameworkEventClassBase event carrying detail, source, cancel/bubble flags
FrameworkEventInitTypeOptions passed when constructing an event
FrameworkEventMapInterfaceExtensible registry mapping event names → event types
FrameworkEventHandlerTypeListener callback signature (sync or async)
IEventModuleProviderInterfacePublic API for the event provider (addEventListener, dispatchEvent, event$)
EventModuleProviderClassDefault provider implementation
EventModuleConfigTypeResolved configuration hooks (onDispatch, onBubble)
EventModuleConfiguratorClassFluent config builder (setOnDispatch, setOnBubble) — see Configuration
IEventModuleConfiguratorTypeDeprecated alias for EventModuleConfig
filterEventFunctionRxJS operator to narrow event$ to a single registered event type
EventModule / eventModuleKeyType / ConstModule definition and key ('event')

Subpaths

SubpathExportsPurpose
./operatorsfilterEventRxJS pipeable operators over event$ (also re-exported from the package root)
./utilswaitForEvent, watchEventsPlain helpers for waiting on / collecting dispatched events, in application code or tests

版本与发布记录

@equinor/fusion-framework-module-event 共发布 102 个版本,首次发布于 2022/08/18;过去 12 个月发布了 17 个版本。

版本发布日期距今
6.1.4latest2026/11/121 天前
6.1.4-next.1next2026/11/112 天前
6.1.4-next.02026/10/2816 天前
6.1.32026/10/1727 天前
6.1.3-trusted-publishing-20261015-9dfe7602cd2a49a8a9df00d62c26e7304a82a85atrusted-publishing-202610152026/10/1629 天前
6.1.22026/10/121 个月前

其他发布通道:apploader → 4.3.7-apploader-be21a6b60eb13eee8bf869e75002d8634e9c50a9,cli-search-index → 4.4.1-cli-search-index.0,msal-v5 → 4.4.1-msal-v5.0,trusted-publishing-20261015 → 6.1.3-trusted-publishing-20261015-9dfe7602cd2a49a8a9df00d62c26e7304a82a85a,next → 6.1.4-next.1。

关于 @equinor/fusion-framework-module-event 的常见问题

@equinor/fusion-framework-module-event 是什么?

Fusion module for events

如何安装 @equinor/fusion-framework-module-event?

在项目目录运行 npm install @equinor/fusion-framework-module-event,或使用 pnpm add / yarn add / bun add。

@equinor/fusion-framework-module-event 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@equinor/fusion-framework-module-event 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@equinor/fusion-framework-module-event 可以商用吗?

@equinor/fusion-framework-module-event 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@equinor/fusion-framework-module-event 的下载量有多少?

根据 npm 官方下载统计,@equinor/fusion-framework-module-event 在 2026/10/14 – 2026/11/12 这 30 天内被下载 12,224 次,日均约 407 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@equinor/fusion-framework-module-event 还在维护吗?

最新版本 6.1.4 发布于 2026/11/12(1 天前);至今共发布 102 个版本,其中过去 12 个月发布了 17 个;首次发布于 2022/08/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。