File tree Expand file tree Collapse file tree 3 files changed +24
-18
lines changed Expand file tree Collapse file tree 3 files changed +24
-18
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ export {
13
13
NetworkButton ,
14
14
AppKit
15
15
} from '@reown/appkit-scaffold-react-native' ;
16
- import type { EventName } from '@reown/appkit-scaffold-react-native' ;
16
+ import type { EventName , EventsControllerState } from '@reown/appkit-scaffold-react-native' ;
17
17
18
18
export { defaultConfig } from './utils/defaultConfig' ;
19
19
@@ -130,7 +130,7 @@ export function useAppKitError() {
130
130
} ;
131
131
}
132
132
133
- export function useAppKitEvents ( ) {
133
+ export function useAppKitEvents ( callback ?: ( newEvent : EventsControllerState ) => void ) {
134
134
if ( ! modal ) {
135
135
throw new Error ( 'Please call "createAppKit" before using "useAppKitEvents" hook' ) ;
136
136
}
@@ -140,17 +140,21 @@ export function useAppKitEvents() {
140
140
useEffect ( ( ) => {
141
141
const unsubscribe = modal ?. subscribeEvents ( newEvent => {
142
142
setEvents ( { ...newEvent } ) ;
143
+ callback ?.( newEvent ) ;
143
144
} ) ;
144
145
145
146
return ( ) => {
146
147
unsubscribe ?.( ) ;
147
148
} ;
148
- } , [ ] ) ;
149
+ } , [ callback ] ) ;
149
150
150
151
return event ;
151
152
}
152
153
153
- export function useAppKitEventSubscription ( event : EventName , callback : ( ) => void ) {
154
+ export function useAppKitEventSubscription (
155
+ event : EventName ,
156
+ callback : ( newEvent : EventsControllerState ) => void
157
+ ) {
154
158
if ( ! modal ) {
155
159
throw new Error ( 'Please call "createAppKit" before using "useAppKitEventSubscription" hook' ) ;
156
160
}
@@ -162,6 +166,4 @@ export function useAppKitEventSubscription(event: EventName, callback: () => voi
162
166
unsubscribe ?.( ) ;
163
167
} ;
164
168
} , [ callback , event ] ) ;
165
-
166
- return event ;
167
169
}
Original file line number Diff line number Diff line change 6
6
NetworkButton ,
7
7
AppKit
8
8
} from '@reown/appkit-scaffold-react-native' ;
9
- import type { EventName } from '@reown/appkit-scaffold-react-native' ;
9
+ import type { EventName , EventsControllerState } from '@reown/appkit-scaffold-react-native' ;
10
10
import {
11
11
ConstantsUtil ,
12
12
EthersStoreUtil ,
@@ -127,7 +127,7 @@ export function useAppKitError() {
127
127
} ;
128
128
}
129
129
130
- export function useAppKitEvents ( ) {
130
+ export function useAppKitEvents ( callback ?: ( newEvent : EventsControllerState ) => void ) {
131
131
if ( ! modal ) {
132
132
throw new Error ( 'Please call "createAppKit" before using "useAppKitEvents" hook' ) ;
133
133
}
@@ -137,17 +137,21 @@ export function useAppKitEvents() {
137
137
useEffect ( ( ) => {
138
138
const unsubscribe = modal ?. subscribeEvents ( newEvent => {
139
139
setEvents ( { ...newEvent } ) ;
140
+ callback ?.( newEvent ) ;
140
141
} ) ;
141
142
142
143
return ( ) => {
143
144
unsubscribe ?.( ) ;
144
145
} ;
145
- } , [ ] ) ;
146
+ } , [ callback ] ) ;
146
147
147
148
return event ;
148
149
}
149
150
150
- export function useAppKitEventSubscription ( event : EventName , callback : ( ) => void ) {
151
+ export function useAppKitEventSubscription (
152
+ event : EventName ,
153
+ callback : ( newEvent : EventsControllerState ) => void
154
+ ) {
151
155
if ( ! modal ) {
152
156
throw new Error ( 'Please call "createAppKit" before using "useAppKitEventSubscription" hook' ) ;
153
157
}
@@ -159,6 +163,4 @@ export function useAppKitEventSubscription(event: EventName, callback: () => voi
159
163
unsubscribe ?.( ) ;
160
164
} ;
161
165
} , [ callback , event ] ) ;
162
-
163
- return event ;
164
166
}
Original file line number Diff line number Diff line change 6
6
NetworkButton ,
7
7
AppKit
8
8
} from '@reown/appkit-scaffold-react-native' ;
9
- import type { EventName } from '@reown/appkit-scaffold-react-native' ;
9
+ import type { EventName , EventsControllerState } from '@reown/appkit-scaffold-react-native' ;
10
10
import { ConstantsUtil } from '@reown/appkit-scaffold-utils-react-native' ;
11
11
export { defaultWagmiConfig } from './utils/defaultWagmiConfig' ;
12
12
import { useEffect , useState , useSyncExternalStore } from 'react' ;
@@ -83,7 +83,7 @@ export function useWalletInfo() {
83
83
return { walletInfo } ;
84
84
}
85
85
86
- export function useAppKitEvents ( ) {
86
+ export function useAppKitEvents ( callback ?: ( newEvent : EventsControllerState ) => void ) {
87
87
if ( ! modal ) {
88
88
throw new Error ( 'Please call "createAppKit" before using "useAppKitEvents" hook' ) ;
89
89
}
@@ -93,17 +93,21 @@ export function useAppKitEvents() {
93
93
useEffect ( ( ) => {
94
94
const unsubscribe = modal ?. subscribeEvents ( newEvent => {
95
95
setEvents ( { ...newEvent } ) ;
96
+ callback ?.( newEvent ) ;
96
97
} ) ;
97
98
98
99
return ( ) => {
99
100
unsubscribe ?.( ) ;
100
101
} ;
101
- } , [ ] ) ;
102
+ } , [ callback ] ) ;
102
103
103
104
return event ;
104
105
}
105
106
106
- export function useAppKitEventSubscription ( event : EventName , callback : ( ) => void ) {
107
+ export function useAppKitEventSubscription (
108
+ event : EventName ,
109
+ callback : ( newEvent : EventsControllerState ) => void
110
+ ) {
107
111
if ( ! modal ) {
108
112
throw new Error ( 'Please call "createAppKit" before using "useAppKitEventSubscription" hook' ) ;
109
113
}
@@ -115,6 +119,4 @@ export function useAppKitEventSubscription(event: EventName, callback: () => voi
115
119
unsubscribe ?.( ) ;
116
120
} ;
117
121
} , [ callback , event ] ) ;
118
-
119
- return event ;
120
122
}
You can’t perform that action at this time.
0 commit comments