-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
refactor(image-source): throw if source is not a correct native instance #5273
Conversation
Please sign CLA at http://www.nativescript.org/cla |
CLA signature found, happy contributing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also think about removing the return value. Why do we need false when we pass null, instead of a simple void method? @PanayotCankov @hshristov
@@ -140,6 +140,9 @@ export class ImageSource implements ImageSourceDefinition { | |||
} | |||
|
|||
public setNativeSource(source: any): boolean { | |||
if (!(source instanceof android.graphics.Bitmap)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this way, the method will no longer return false, it will throw an exception instead. It could be something like:
if (source && !(source instanceof android.graphics.Bitmap))
@@ -119,9 +119,10 @@ export class ImageSource implements ImageSourceDefinition { | |||
} | |||
|
|||
public setNativeSource(source: any): boolean { | |||
if (source instanceof UIImage) { | |||
this.ios = source; | |||
if (!(source instanceof UIImage)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this way, the method will no longer return false, it will throw an exception instead. It could be something like:
if (source && !(source instanceof UIImage))
f117a10
to
d5e3a29
Compare
Thank you, @DimitarTachev! |
public setNativeSource(source: any): boolean { | ||
if (source instanceof UIImage) { | ||
this.ios = source; | ||
public setNativeSource(source: any): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a change in the public API -> mark this as breaking change if it is really needed.
Also the definitions (image-source.d.ts
) should be updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks.
d5e3a29
to
17d04e8
Compare
BREAKING CHANGE: Change the return type of `setNativeSource` method from `boolean` to `void`.
Changes are done, branch is rebased and able to merge after green CI. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
#3605