API reference

5.0.0-beta.1 · Published beta · b06750c5. Published on npm. Match your installed version.

Public API index#

Use this index to identify the supported import and follow its behavior contract. The marionette package has named exports; it has no default export. Import optional integrations from their documented package subpaths, never from src/ or generated internal files.

Core runtime exports#

Export Purpose and reference
View Render and own one part of the interface.
CollectionView Own ordered child Views.
Region Show, replace, detach, or destroy a current View.
Application Coordinate asynchronous feature lifecycle and child Applications.
Behavior Share host View interactions and lifecycle.
MnObject Own nonvisual events, State, and synchronous cleanup.
Events Compose the event/listening contract.
Radio Use the default runtime's named message channels.
DataApi, setDataApi Read and observe the selected data source.
StateApi, setStateApi Observe State and dispose owned sources.
DomApi, setDomApi Create, query, attach, and update DOM.
setRenderer Configure synchronous template evaluation.
setEventDelegator Configure DOM event registration and cleanup.
createMarionette Create independent classes, configuration, and Radio.
monitorViewEvents Bridge lifecycle notifications for supported custom Views.
extend Extend a function constructor.
MarionetteError Inspect a framework invariant failure.
VERSION Read the package version.

Configuration method contracts identify which classes each setter affects, its return value, and its scope. Choosing one provider does not configure the other providers.

monitorViewEvents(view)#

This synchronous helper installs lifecycle listeners on a supported custom View and returns undefined. It propagates attachment and detachment notifications to managed children and derives dom:refresh/dom:remove from render and attachment state. Repeating the call does not install duplicate monitoring; monitorViewEvents: false skips installation.

Marionette Views are monitored automatically. This helper is for integrations that implement the supported View lifecycle, including event methods and managed-child access. It is not a MutationObserver: appending arbitrary DOM does not notify it. Prefer a Marionette wrapper View for third-party widgets so ownership and cleanup remain explicit.

Companion packages#

Import Public surface Reference
@mnjs/data Model, Collection, DataApi, StateApi, triggerMethod Native observable data
@mnjs/radio Radio, createRadio, Channel, Requests Standalone Radio
@mnjs/utils Shared events, bindings, option, inheritance, and event-building helpers Utility exports
@mnjs/adapters/backbone Default Backbone data/State adapter Backbone integration
@mnjs/adapters/xstate Default createXStateActorApi factory XState integration
@mnjs/adapters/dom/jquery Default jQuery DomApi jQuery DOM
@mnjs/adapters/dom/morphdom Default Morphdom DomApi DOM update adapters
@mnjs/adapters/dom/lit-html Default Lit DomApi DOM update adapters

Add a companion package as a direct dependency when application code imports it. Match Marionette package versions during prereleases. Optional integrations need only their selected peers; see Choosing integrations.

TypeScript exports#

Core also exports types for class instances and constructors, class configuration, Region definitions and show options, Application readiness context, DOM events and triggers, UI bindings, Behavior definitions, event and request contracts, and provider contracts (DataApiContract, DomApiContract, StateApiContract, EventDelegator, and Renderer). Use import type for these names. They do not create runtime values or install a provider.

The package's declarations are the exact signature reference. Keep inferred subclass types when possible rather than annotating an extended View as the broad base instance type and losing its application-specific methods.