Skip to content

Commit

Permalink
Merge pull request #281 from quiltt/events-ready
Browse files Browse the repository at this point in the history
Add bindings for a new onOpen callback event for Connector Modals
  • Loading branch information
sirwolfgang authored Jul 31, 2024
2 parents 597f3fe + 0c5fd75 commit 88a30d8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/khaki-bulldogs-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@quiltt/react": minor
"@quiltt/core": minor
"@quiltt/react-native": minor
---

Add bindings for a new onOpen callback event for Connector Modals
4 changes: 4 additions & 0 deletions packages/core/src/api/browser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
interface CallbackManager {
onEvent(callback: ConnectorSDKOnEventCallback): void
onOpen(callback: ConnectorSDKOnOpenCallback): void
onLoad(callback: ConnectorSDKOnLoadCallback): void
onExit(callback: ConnectorSDKOnEventExitCallback): void
onExitSuccess(callback: ConnectorSDKOnExitSuccessCallback): void
Expand All @@ -8,6 +9,7 @@ interface CallbackManager {

// Because it's well within React behavior to try to register a billion functions
offEvent(callback: ConnectorSDKOnEventCallback): void
offOpen(callback: ConnectorSDKOnOpenCallback): void
offLoad(callback: ConnectorSDKOnLoadCallback): void
offExit(callback: ConnectorSDKOnEventExitCallback): void
offExitSuccess(callback: ConnectorSDKOnExitSuccessCallback): void
Expand Down Expand Up @@ -35,6 +37,7 @@ export interface ConnectorSDKConnector extends CallbackManager {
*/
export type ConnectorSDKCallbacks = {
onEvent?: ConnectorSDKOnEventCallback
onOpen?: ConnectorSDKOnOpenCallback
onLoad?: ConnectorSDKOnLoadCallback
onExit?: ConnectorSDKOnEventExitCallback
onExitSuccess?: ConnectorSDKOnExitSuccessCallback
Expand All @@ -47,6 +50,7 @@ export type ConnectorSDKOnEventCallback = (
metadata: ConnectorSDKCallbackMetadata
) => void

export type ConnectorSDKOnOpenCallback = (metadata: ConnectorSDKCallbackMetadata) => void
export type ConnectorSDKOnLoadCallback = (metadata: ConnectorSDKCallbackMetadata) => void

export type ConnectorSDKOnEventExitCallback = (
Expand Down
2 changes: 2 additions & 0 deletions packages/react/src/components/QuilttButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const QuilttButton = <T extends AnyTag = 'button'>({
connectionId,
institution,
onEvent,
onOpen,
onLoad,
onExit,
onExitSuccess,
Expand All @@ -32,6 +33,7 @@ export const QuilttButton = <T extends AnyTag = 'button'>({
connectionId,
institution,
onEvent,
onOpen,
onLoad,
onExit,
onExitSuccess,
Expand Down
9 changes: 9 additions & 0 deletions packages/react/src/hooks/useQuilttConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ export const useQuilttConnector = (
return () => connector.offEvent(options.onEvent as any)
}, [connector, options?.onEvent])

// onOpen
useEffect(() => {
if (!connector || !options?.onOpen) return

connector.onOpen(options.onOpen)
return () => connector.offOpen(options.onOpen as any)
}, [connector, options?.onOpen])


// onLoad
useEffect(() => {
if (!connector || !options?.onLoad) return
Expand Down

0 comments on commit 88a30d8

Please sign in to comment.