Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codegen and adding listeners #48911

Closed
fgrs opened this issue Jan 23, 2025 · 6 comments
Closed

Codegen and adding listeners #48911

fgrs opened this issue Jan 23, 2025 · 6 comments
Labels
Newer Patch Available Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed.

Comments

@fgrs
Copy link

fgrs commented Jan 23, 2025

Description

I'm following this documentation https://reactnative.dev/docs/turbo-native-modules-introduction#1-declare-typed-specification to extend my native module with onError listener. My first issue is when I try to add new function interface in the Spec file

addListener(eventName: string): void // Add an event listener
removeListeners(count: number): void // Remove event listeners

and update kotlin file with

fun removeListeners(count: Int) {
    listenerCount -= count
}

the build fails due to 'count' being an Int.

My second issue is that I don't know how to subscribe to onError using New Architecture and the Spec file instead of importing NativeEventEmitter and NativeModules

I appreciate any help

Steps to reproduce

yarn android

React Native Version

0.76.3

Affected Platforms

Runtime - Android

Areas

TurboModule - The New Native Module System

Output of npx react-native info

System:
  OS: macOS 15.1.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 104.56 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 23.3.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.21
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.8.1
    path: /usr/local/bin/npm
  Watchman:
    version: 2024.12.02.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10811636
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 18.0.1.1
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.3
    wanted: 0.76.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

BUILD FAILED in 2s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
e: file:///.../NativeNfcManagerModule.kt:26:1 Class 'NativeNfcManagerModule' is not abstract and does not implement abstract base class member public abstract fun removeListeners(count: Double): Unit defined in com.nativenfcmanager.NativeNfcManagerSpec
e: file:///.../NativeNfcManagerModule.kt:60:7 'addListener' hides member of supertype 'NativeNfcManagerSpec' and needs 'override' modifier FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction > Compilation error. See log for more details * Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org. BUILD FAILED in 2s.
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Reproducer

sorry no link

Screenshots and Videos

No response

@fgrs fgrs added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Jan 23, 2025
@react-native-bot react-native-bot added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Newer Patch Available labels Jan 23, 2025
@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - 0.76.6. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@react-native-bot
Copy link
Collaborator

Warning

Missing reproducer: We could not detect a reproducible example in your issue report. Please provide either:

@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@fgrs
Copy link
Author

fgrs commented Jan 23, 2025

Update: a solution to issue 1 was to change in kotlin: removeListeners(count: Double)

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Jan 23, 2025
@princektripathi
Copy link
Collaborator

@fgrs, I would suggest you to leverage platforms like Stackoverflow or https://www.reactiflux.com/. This space is primarily for issues reporting.

@migueldaipre migueldaipre added the Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. label Jan 24, 2025
@react-native-bot
Copy link
Collaborator

Note

Not a bug report: This issue looks like a question. We are using GitHub issues exclusively to track bugs in React Native. GitHub may not be the ideal place to ask a question, but you can try asking over on Stack Overflow, or on Reactiflux.

@migueldaipre migueldaipre removed Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Attention Issues where the author has responded to feedback. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Newer Patch Available Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed.
Projects
None yet
Development

No branches or pull requests

4 participants