Skip to content

Conversation

@KrzysztofMoch
Copy link
Collaborator

Summary

Refactor events logic

Prev:

var onEvent: (arg) -> void

Now:

var addOnEvent((arg) => { callback }): ListenerSubscription

Also updated Nitro to 0.31.10

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the events logic in react-native-video from a property-based callback system to a subscription-based event listener pattern. The main changes include converting event callbacks from settable properties (onEvent: (arg) => void) to methods that return ListenerSubscription objects (addOnEventListener((arg) => { callback }): ListenerSubscription). Additionally, the Nitro modules dependency is updated from version 0.30.0 to 0.31.0.

Key changes:

  • Introduced ListenerSubscription interface with a remove() method for managing event subscriptions
  • Converted all event properties to addOn*Listener() methods in both VideoPlayerEventEmitter and VideoViewViewManager
  • Updated event handling in VideoView.tsx to register/cleanup subscriptions via useEffect hooks
  • Refactored VideoPlayerEvents class to use the new subscription-based API

Reviewed changes

Copilot reviewed 22 out of 177 changed files in this pull request and generated no comments.

Show a summary per file
File Description
VideoPlayerEventEmitter.nitro.ts Added ListenerSubscription interface and converted all event properties to listener methods
VideoViewViewManager.nitro.ts Removed VideoViewEvents extension, added listener methods for view events
Events.ts Separated JS-only events (JSVideoPlayerEvents) from native events, added ALL_VIEW_EVENTS
VideoView.tsx Refactored to register event listeners via useEffect with proper cleanup
useEvent.ts Updated hook to use subscription.remove() instead of removeEventListener
VideoPlayerEvents.ts Refactored to use addOn*Listener methods with switch-case mapping
VideoPlayer.ts Renamed triggerEvent to triggerJSEvent for clarity
package.json Updated nitrogen and react-native-nitro-modules from 0.30.0 to 0.31.0
nitrogen/generated/* Generated code updates for new Nitro version and ListenerSubscription support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KrzysztofMoch KrzysztofMoch merged commit 3c9bae7 into v7 Dec 11, 2025
10 checks passed
@KrzysztofMoch KrzysztofMoch deleted the refactor-v7/events branch December 11, 2025 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants