GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Document @NativeClass and co. · Issue #12 · NativeScript/docs

Document @NativeClass and co. #12

New issue
Copy link
New issue
Copy link
Open
Open
Document @NativeClass and co.#12
Copy link

Description

@rigor789
rigor789
opened on Nov 18, 2022
Issue body actions

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.

Activity

  1. rigor789 commented on Nov 18, 2022

    @rigor789
    rigor789
    on Nov 18, 2022
    MemberAuthor
    More actions

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

    Reacted by Juan de Dios Martínez Vallejo
  2. rigor789
    added this to NativeScript Docs Projecton Nov 18, 2022
  3. rigor789
    moved this to 📋 Backlog in NativeScript Docs Projecton Nov 18, 2022
  4. vallemar commented on Nov 22, 2022

    @vallemar
    vallemar
    on Nov 22, 2022
    Contributor
    More actions

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • NativeScript Docs Project
      Status
      📋 Backlog
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.