Skip to content

Commit b7b42ae

Browse files
authored
Merge pull request #35 from farfromrefug/constructor_opt_native
feat: optionally pass native instance to constructor
2 parents 5a16beb + 5bc80da commit b7b42ae

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

packages/canvas/ImageAsset/ImageAsset.android.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { ImageAssetBase, ImageAssetSaveFormat } from './common';
22
import { knownFolders, path as filePath } from '@nativescript/core';
33

44
export class ImageAsset extends ImageAssetBase {
5-
constructor() {
6-
super(new org.nativescript.canvas.TNSImageAsset());
5+
constructor(native?: org.nativescript.canvas.TNSImageAsset) {
6+
super(native || new org.nativescript.canvas.TNSImageAsset());
77
}
88

99
get width() {

packages/canvas/ImageAsset/ImageAsset.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export declare class ImageAsset extends ImageAssetBase {
55
height: number;
66
error: string;
77

8-
constructor();
8+
constructor(native?: any);
99

1010
loadFromUrl(url: string): boolean;
1111

packages/canvas/ImageAsset/ImageAsset.ios.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ const main_queue = dispatch_get_current_queue();
77
const background_queue = dispatch_get_global_queue(21, 0);
88

99
export class ImageAsset extends ImageAssetBase {
10+
//@ts-ignore
1011
native: TNSImageAsset
11-
constructor() {
12-
super(TNSImageAsset.alloc().init());
12+
constructor(native?: TNSImageAsset) {
13+
super(native || TNSImageAsset.alloc().init());
1314
}
1415

1516
get width() {

0 commit comments

Comments
 (0)