Overview
The message system consists of:- Msg - Top-level message enum containing Action, Event, or Internal
- Action - Messages dispatched by users of stremio-core
- Event - Messages dispatched by stremio-core to be handled externally
- Internal - Messages used internally within stremio-core
Msg
The top-level message type that wraps all message categories.Variants
Action- User-initiated actionsInternal- Internal core messages (async results, state changes)Event- Events emitted to external systems (analytics, UI updates)
Action
Actions represent user inputs and requests to modify state or trigger operations.ActionCtx
Actions related to the global context (authentication, profile, addons, library).ActionPlayer
Actions related to video playback.ActionMetaDetails
Actions for the meta details screen.ActionLoad
Actions to load specific models/screens.ActionStreamingServer
Actions for streaming server operations.ActionCatalogWithFilters
Actions for catalog browsing.ActionSearch
Actions for search functionality.Event
Events are emitted by stremio-core to notify external systems of state changes and important occurrences.Internal
Internal messages are used within stremio-core for async operation results and internal state coordination.Message Flow
- User dispatches an Action
- Model processes the action in
update() - Model returns Effects
- Runtime executes effects asynchronously
- Effects produce Internal messages with results
- Model processes internal messages
- Model emits Events for external systems
Best Practices
Use appropriate message types
Use appropriate message types
- Action: User inputs, requests from external code
- Event: Notifications to external systems, analytics
- Internal: Async results, internal state coordination
Always handle async results
Always handle async results
Every async effect should produce an Internal message with the result, which the model must handle.
Emit events for important state changes
Emit events for important state changes
Use Events to notify external systems of important occurrences like authentication, library changes, playback events.
Keep messages serializable (Actions)
Keep messages serializable (Actions)
Action messages are deserializable from JSON, making them easy to dispatch from different environments (JS, native, etc.).
