Nested Component Event Bubbling
I'm working with a Rive animation that has a nested artboard (component) containing its own state machine with events. I've noticed a discrepancy between what I see in the Rive editor console vs what my JavaScript runtime receives, and I'd like to clarify if this is expected behavior.
Setup:
Main artboard with state machine
Nested artboard (component) with its own state machine that fires events
Listeners in the main artboard's state machine, attached to the nested components that listen for nested events and re-emit/fire similarly named events at the main artboard level
What I see in the Rive Editor console:
When I run the animation in the editor, the console shows BOTH:
The original events from the nested artboard (e.g., nested-event-start)
The re-emitted events fired by my Listeners (e.g., main-event-start)
BUT, in the browser, using the standard event listener pattern, I only receive the re-emitted events - the original nested artboard events never appear:
const riveInstance = new rive.Rive({
src: 'animation.riv',
canvas: document.getElementById('canvas'),
autoplay: true,
stateMachines: ['main-state-machine'],
onLoad: () => {
console.log('Loaded');
}
});
// Listening for events
riveInstance.on(rive.EventType.RiveEvent, (ev) => {
console.log('Event received:', ev.data?.name);
console.log('Full event data:', ev.data);
});Questions:
Is this expected behavior - that nested artboard events are only visible internally to the editor but not exposed to the JS runtime?
Is using Listeners to "bubble up" nested events (catch them and re-fire at main artboard level) the correct/recommended pattern for accessing neste component events at runtime?