RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • addlistener
    • addParameter
    • addprop
    • assignin
    • builtin
    • cancel
    • class
    • clear
    • clearAllMemoizedCaches
    • clearCache
    • clearvars
    • dbclear
    • dbstack
    • dbstatus
    • dbtype
    • eval
    • evalc
    • evalin
    • feval
    • findprop
    • func2str
    • functions
    • get.p
    • getcallinfo
    • getmethod
    • inputname
    • inputParser
    • isa
    • ischar
    • isdeployed
    • iskeyword
    • ismethod
    • isobject
    • isstring
    • isUnderlyingType
    • isvalid
    • keyboard
    • loadobj
    • localfunctions
    • matlab.metadata.DynamicProperty.delete
    • memoize
    • metaclass
    • mfilename
    • mislocked
    • mlock
    • munlock
    • namelengthmax
    • narginchk
    • nargoutchk
    • new_object
    • notify
    • numArgumentsFromSubscript
    • onCleanup
    • parse
    • saveobj
    • set.p
    • stats
    • str2func
    • subsasgn
    • subsref
    • superclasses
    • underlyingType
    • verLessThan
    • version
    • which
    • who
    • whos

addlistener — Register a callback on a handle-object event.

listener = addlistener(target,event_name,callback) registers a callback with the current runtime event registry and returns a listener value. Registration occurs even when the result is discarded.

Syntax

listener = addlistener(target, event_name, callback)
addlistener(target, event_name, callback)

Inputs

target
Type
Any
Required
Yes
Default
—
Description
Live handle-object event source.
event_name
Type
StringScalar
Required
Yes
Default
—
Description
Case-sensitive event name.
callback
Type
Any
Required
Yes
Default
—
Description
Function handle or textual callback reference.
NameTypeRequiredDefaultDescription
targetAnyYes—Live handle-object event source.
event_nameStringScalarYes—Case-sensitive event name.
callbackAnyYes—Function handle or textual callback reference.

Returns

listener
Type
Any
Description
Registered listener value.
NameTypeDescription
listenerAnyRegistered listener value.

Errors

RunMat:AddListenerTargetInvalid
When
Target is not a live handle object.
Message
addlistener: target must be a valid handle object
RunMat:addlistener:TooManyOutputs
When
More than one output is explicitly requested.
Message
addlistener: expected at most one output
RunMat:AddListenerAllocationFailed
When
GC rooting or listener allocation fails before registration.
Message
addlistener: failed to retain listener target or callback
IdentifierWhenMessage
RunMat:AddListenerTargetInvalidTarget is not a live handle object.addlistener: target must be a valid handle object
RunMat:addlistener:TooManyOutputsMore than one output is explicitly requested.addlistener: expected at most one output
RunMat:AddListenerAllocationFailedGC rooting or listener allocation fails before registration.addlistener: failed to retain listener target or callback
RunMat:AddListenerCallbackInvalidCallback is not a supported nonempty callable or scalar text handle.addlistener: callback must be callable or scalar text
RunMat:AddListenerEventUnknownThe target class or its superclasses do not declare the named event.addlistener: unknown event
RunMat:AddListenerEventAccessThe active class context lacks declared ListenAccess.addlistener: event is not accessible
RunMat:AddListenerEventChangedThe event declaration changes before listener publication.addlistener: event changed during registration

Receiver and callback

The receiver must be a live handle object. Event names are case-sensitive text. The callback may be a bound function handle, closure, supported named handle, or textual function reference. Text references are resolved through the current semantic function catalog when possible; callback invocation occurs later in notify.

The event registry retains explicit GC roots for target and callback until registration invalidation. The current implementation does not verify that the class declared the event or that the callback signature matches at registration time.

Numeric or GPU-resident values are not direct target, event-name, or callback controls. Values captured by a callback remain under that callback's ordinary ownership rules and are not gathered by addlistener.

Execution and output

Native and browser hosts use the context-owned event registry. Registration is a host mutation and a fusion boundary, not a GPU kernel or automatically replayable operation. A worker's independent object registry does not inherit the originating listener.

At most one output is available; a zero-output statement still registers the listener. Current listener invalidation and target lifetime are managed by the runtime's listener/GC services.

Example

Register an event callback

h = new_handle_object('EventTarget'); listener = addlistener(h, 'Changed', @disp);

Using addlistener with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how addlistener changes the result.

Run a small addlistener example, explain the result, then change one input and compare the output.

FAQ

Does registration invoke the callback?⌄

No. notify invokes enabled, valid listeners in registry order; registration only retains the target and callback.

Related Introspection functions

addParameter · addprop · assignin · builtin · cancel · class · clear · clearAllMemoizedCaches · clearCache · clearvars · dbclear · dbstack · dbstatus · dbtype · eval · evalc · evalin · feval · findprop · func2str · functions · get.p · getcallinfo · getmethod · inputname · inputParser · isa · ischar · isdeployed · iskeyword · ismethod · isobject · isstring · isUnderlyingType · isvalid · keyboard · loadobj · localfunctions · matlab.metadata.DynamicProperty.delete · memoize · metaclass · mfilename · mislocked · mlock · munlock · namelengthmax · narginchk · nargoutchk · new_object · notify · numArgumentsFromSubscript · onCleanup · parse · saveobj · set.p · stats · str2func · subsasgn · subsref · superclasses · underlyingType · verLessThan · version · which · who · whos

Source you can read

Every RunMat function's source is public. Read exactly how addlistener is executed, line by line, in Rust.

  • View the source for addlistener in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Receiver and callback
  • Execution and output
  • Example
  • Register an event callback
  • Using addlistener with coding agents
  • FAQ
  • Related Introspection functions
  • Source you can read
  • About RunMat