Bringing the Scene to Life with Navix Lifecycle
03 //How much room do lifecycle events give a developer?
The core lifecycle events are onRegister, onUnregister, onFocus, onBlurred, and onEvent. Combined with props like focusOnRegister and disabled, they open up quite a wide space.
onEvent is the most flexible. Every key press first reaches the deepest focused node; if that node returns true, the event is considered consumed and doesn't bubble up. This lets any component intercept whichever key it wants, run its own logic, and leave the rest to the tree.
focusOnRegister is a small but practical prop. The moment a component registers in the tree, it pulls focus to itself. Instead of manually managing where the first focus lands in a modal or newly opened screen, this prop is enough.
disabled is not just a visual flag. It's tied to the canReceiveFocus mechanism; a disabled node cannot receive focus, and focusNext and focusPrev automatically skip it.
Where's the limit? Lifecycle events operate at the component level; there's no central event listener spanning multiple components. For one component to directly track another's focus state, they need to communicate through a shared parent. This is an intentional design decision: each component carries its own responsibility, the tree coordinates the whole.
04 //How did the MediaCard in the demo evolve?
At first we tried controlling events from outside — tracking which card was visible from the parent component and passing it down as a prop seemed reasonable. But as the demo grew, this approach became messy with every new feature. Eventually it became clear that caching and playback responsibility needed to stay entirely inside the card. onRegister took ownership of entering the visible area, onFocus of focusing, onBlurred and onUnregister of cleanup. Only one thing needed to be coordinated externally: the card says what it wants, how that's fulfilled is no longer the card's concern.
05 //How would you extend this system in a real application?
The component's lifecycle events only communicate the request; determining how the request is fulfilled is the application's responsibility. In a real scenario a central manager steps in: this layer decides how many items can be cached simultaneously and which get priority. The component reports its cache request to the manager on onRegister, passes its playback request on onFocus, and cancels on onUnregister. The manager then queues these requests with the device's resources in mind. This way, while components keep the scene alive, how much load builds up in the background stays under control.