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
[android][expo-sharing] migrate to new modules API #20112
Changes from all commits
016c4e3
5255935
3065bfe
e24c0a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package expo.modules.sharing | ||
|
||
import expo.modules.kotlin.exception.CodedException | ||
|
||
internal class MissingCurrentActivityException : | ||
CodedException("Activity which was provided during module initialization is no longer available") | ||
|
||
internal class SharingInProgressException : | ||
CodedException("Another share request is being processed now.") | ||
|
||
internal class SharingFailedException(message: String, e: Exception) : | ||
CodedException(message, e.cause) | ||
|
||
internal class SharingInvalidArgsException(message: String?, e: Exception) : | ||
CodedException(message, e.cause) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package expo.modules.sharing | ||
|
||
import expo.modules.kotlin.records.Field | ||
import expo.modules.kotlin.records.Record | ||
|
||
data class SharingOptions( | ||
@Field val mimeType: String?, | ||
@Field val UTI: String?, | ||
@Field val dialogTitle: String? | ||
) : Record |
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "expo-sharing", | ||
"platforms": ["ios", "android"], | ||
"android": { | ||
"modules": ["expo.modules.sharing.SharingModule"] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
import { NativeModulesProxy } from 'expo-modules-core'; | ||
|
||
export default NativeModulesProxy.ExpoSharing; | ||
import { requireNativeModule } from 'expo-modules-core'; | ||
export default requireNativeModule('ExpoSharing'); |
This file was deleted.
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.
Overall, it looks great, but you can't just remove that function and resolve the promise earlier. The time when the promise will be resolved will be different.
Before:
js calls
shareAsync
-> intent is invoked -> share activity was opened -> user shares something -> execution goes back to the application -> the promise is resolvedNow:
js calls
shareAsync
-> intent is invoked -> promise is resolvedIn many cases, the flow from the js perspective looks similar, because when the rn app goes to the background (when the shared activity is active), there is a small time window when the app code can still execute. However, it not always may be true.
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.
Yeah, I thought this mightn't be right. I'll put it back. So resolving with null is just a way of notifying the js that an action has been completed? You'd only need to do this in situations where it's some kind of callback? If it all completes inside the AsyncFunction body, you can just let the function complete without resolving if you are not returning anything?
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.
Yes, exactly. The
AsyncFunction
will automatically callpromise.resolve(null)
if the closure doesn't take the promise as an argument and the function is complete. In the case where a promise is the last argument of the function, you take responsibility for managing the promise itself. It's helpful when the function is completed, but the rest of the operation happens on a different thread.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.
Great, that makes sense, thanks Łukasz 👍