Last active
October 28, 2020 18:30
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* {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