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

Document @NativeClass and co. #12

Open
rigor789 opened this issue Nov 18, 2022 · 2 comments
Open

Document @NativeClass and co. #12

rigor789 opened this issue Nov 18, 2022 · 2 comments

Comments

@rigor789
Copy link
Member

From @vallemar

...how and when to use the @nativeclass or @interface annotations, also how to add delegates in iOS. In general, how to access native under the most common situations

Example android class
@NativeClass()
@Interfaces([android.hardware.SensorEventListener])
class SensorEventListenerAndroid
  extends java.lang.Object
  implements android.hardware.SensorEventListener
{
  callback: (event: number[]) => void;
  callbackOnAccuracyChanged: (
    sensor: android.hardware.Sensor,
    accuracy: number
  ) => void;

  constructor(callback: (data) => void) {
    super();
    this.callback = callback;
    return global.__native(this);
  }

  onAccuracyChanged(sensor: android.hardware.Sensor, accuracy: number): void {
    if (this.callbackOnAccuracyChanged) {
      this.callbackOnAccuracyChanged(sensor, accuracy);
    }
  }

  onSensorChanged(event: android.hardware.SensorEvent): void {
    if (!event || (event.values.length === 0 && event.values[0])) return;
    this.callback(event.values as number[]);
  }
}

export { SensorEventListenerAndroid };

Document:

  • @NativeClass
  • @ObjCProtocols
  • @JavaProxy
  • @Interfaces
  • ... ?

Eventually, we'll consolidate all of these into the @NativeClass as parameters, but until then, let's document all of these.

@rigor789
Copy link
Member Author

Reference: https://v6.docs.nativescript.org/core-concepts/android-runtime/binding-generator/extend-class-interface#interfaces

@vallemar
Copy link
Contributor

I've seen some notations in plugins, like @Profile, @csstype, and @cssProperty. I'm just leaving it here to collect. I think they have nothing to do with the previous ones but well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants