-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[connect] Add component event listeners (#9690)
* refactor `onSetterFunctionCalled` message handling * add component listening and events * tests and ergonomics * show toast on error for demo
- Loading branch information
1 parent
98f5f85
commit 2edfbfb
Showing
14 changed files
with
413 additions
and
59 deletions.
There are no files selected for viewing
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
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
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
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
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
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
27 changes: 27 additions & 0 deletions
27
connect/src/main/java/com/stripe/android/connect/StripeEmbeddedComponentListener.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.stripe.android.connect | ||
|
||
import com.stripe.android.connect.webview.serialization.SetterFunctionCalledMessage | ||
|
||
@PrivateBetaConnectSDK | ||
interface StripeEmbeddedComponentListener { | ||
/** | ||
* The component executes this callback function before any UI is displayed to the user. | ||
*/ | ||
fun onLoaderStart() {} | ||
|
||
/** | ||
* The component executes this callback function when a load failure occurs. | ||
*/ | ||
fun onLoadError(error: Throwable) {} | ||
} | ||
|
||
@OptIn(PrivateBetaConnectSDK::class) | ||
internal fun interface ComponentListenerDelegate<Listener : StripeEmbeddedComponentListener> { | ||
fun Listener.delegate(message: SetterFunctionCalledMessage) | ||
|
||
companion object { | ||
internal fun <Listener : StripeEmbeddedComponentListener> ignore(): ComponentListenerDelegate<Listener> { | ||
return ComponentListenerDelegate { _ -> } | ||
} | ||
} | ||
} |
Oops, something went wrong.