Skip to content

Instantly share code, notes, and snippets.

@NathanWalker
Last active October 28, 2020 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NathanWalker/2f8234fd900ceb9dac94b2b411d4960d to your computer and use it in GitHub Desktop.
Save NathanWalker/2f8234fd900ceb9dac94b2b411d4960d to your computer and use it in GitHub Desktop.
Example of using a single file containing a single @nativeclass decorated class with NativeScript 7
/**
* {N} 7 uses es2017 targeting
* @NativeClass decorator transforms native class extensions to work with iOS/Android runtimes
* When used in a single file by itself, the transformation modifies the esm export syntax
* Without any other esm exports in the file, you will want to export the symbol at bottom explicitly
* This will ensure a proper esm export of your extended native class symbol will work as expected.
*/
@NativeClass()
class MyNativeClassExt extends NSObject {
// custom extended behavior
}
export { MyNativeClassExt }
// You can now import MyNativeClassExt as normal for usage throughout your {N} codebase and it will work as expected
// This example shows iOS as an example but the same applies for Android
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment