EventManager
TheEventManager
handles event subscriptions and dispatching within a AppSession
. It provides methods for subscribing to various event types from the MentraOS platform.
You access the EventManager through the events
property of a AppSession
instance:
Event Handler Methods
onTranscription()
Registers a handler for real-time speech transcription events.handler
: Callback function that receivesTranscriptionData
objects
onHeadPosition()
Registers a handler for head position change events.handler
: Callback function that receivesHeadPosition
objects
onButtonPress()
Registers a handler for hardware button press events on the glasses.handler
: Callback function that receivesButtonPress
objects
onPhoneNotifications()
Registers a handler for notifications received from the connected phone.handler
: Callback function that receivesPhoneNotification
objects
onGlassesBattery()
Registers a handler for glasses battery update events.handler
: Callback function that receivesGlassesBatteryUpdate
objects
onPhoneBattery()
Registers a handler for phone battery update events.handler
: Callback function that receivesPhoneBatteryUpdate
objects
onVoiceActivity()
Registers a handler for Voice Activity Detection (VAD) events.handler
: Callback function that receivesVad
objects
onLocation()
An event handler for raw location updates. Use theLocationManager
to access location data, as it provides a simple interface for both streaming and polling.
handler
: Callback function that receivesLocationUpdate
objects
onCalendarEvent()
Registers a handler for calendar event notifications.handler
: Callback function that receivesCalendarEvent
objects
onAudioChunk()
Registers a handler for raw audio data chunks. Requires explicit subscription.handler
: Callback function that receivesAudioChunk
objects
System Event Handlers
onConnected()
Registers a handler for when the WebSocket connection is successfully established and authenticated.handler
: Callback function that receives optionalAppSettings
upon connection
onDisconnected()
Registers a handler for when the WebSocket connection is closed or lost.handler
: Callback function that receives a reason string
onError()
Registers a handler for WebSocket or SDK-level errors.handler
: Callback function that receives aWebSocketError
or standard Error object
onSettingsUpdate()
Registers a handler for when the application settings are updated by the user via MentraOS Cloud.handler
: Callback function that receives the complete updatedAppSettings
array
onSettingChange()
Registers a handler that triggers only when a specific setting’s value changes.key
: The key of the setting to monitorhandler
: Callback function that receives the new value and the previous value (or undefined initially)
Generic Event Handler
on()
Generic event handler for any StreamType. Use specific methods above where possible.type
: TheStreamType
to listen forhandler
: Callback function that receives data of the appropriate type for the specified StreamType