9.1.4 • Published 6 days ago
@soroban-react/events v9.1.4
@soroban-react/events
See the official gitbook: https://soroban-react.gitbook.io/index/
import { useSorobanEvents, EventSubscription } from '@soroban-react/events'
const crowdfundPledgedEventSubscription: EventSubscription = {
contractId: Constants.CrowdfundId,
topics: ['pledged_amount_changed'],
cb: (event: SorobanClient.SorobanRpc.EventResponse): void => {
let eventTokenBalance = xdr.ScVal.fromXDR(event.value.xdr, 'base64')
setTokenBalance(convert.scvalToBigNumber(eventTokenBalance))
},
id: Math.random()}
const crowdfundTargetReachedSubscription: EventSubscription = {
contractId: Constants.CrowdfundId,
topics: ['target_reached'],
cb: (event: SorobanClient.SorobanRpc.EventResponse): void => {
setTargetReached(true)
},
id: Math.random()}
const sorobanEventsContext = useSorobanEvents()
React.useEffect(() => {
const pledgedSubId = sorobanEventsContext.subscribe(crowdfundPledgedEventSubscription)
const reachedSubId = sorobanEventsContext.subscribe(crowdfundTargetReachedSubscription)
return () => {
sorobanEventsContext.unsubscribe(pledgedSubId);
sorobanEventsContext.unsubscribe(reachedSubId);
}
}, [sorobanEventsContext]);
9.1.4
6 days ago
9.1.3
13 days ago
9.1.2
14 days ago
9.0.4
2 months ago
9.0.3
2 months ago
9.0.2
2 months ago
9.0.0
3 months ago
8.0.0
5 months ago
7.4.0
5 months ago
5.3.3
10 months ago
5.3.2
10 months ago
6.1.0
9 months ago
6.1.1
9 months ago
6.4.1
9 months ago
6.4.0
9 months ago
7.0.0
8 months ago
7.3.1
6 months ago
7.2.2
6 months ago
7.3.0
6 months ago
6.0.0-alpha.0
10 months ago
7.1.1
7 months ago
7.1.0
7 months ago
7.3.4
6 months ago
7.2.3
6 months ago
7.3.6
6 months ago
5.3.12
10 months ago
5.3.9
10 months ago
5.3.11
10 months ago
5.3.8
10 months ago
5.3.10
10 months ago
5.3.6
10 months ago
5.3.5
10 months ago
5.3.4
10 months ago
5.3.1
11 months ago
5.2.0
11 months ago
5.1.0
11 months ago
5.0.1-alpha.0
12 months ago
5.0.3
12 months ago
5.0.2-alpha.0
12 months ago
4.5.1-alpha.1
12 months ago
5.0.3-alpha.0
12 months ago
4.5.1-alpha.0
12 months ago
4.4.1
12 months ago
4.5.2
12 months ago
4.5.1
12 months ago
5.0.3-alpha.1
12 months ago
5.0.0-alpha.0
12 months ago
4.3.1
1 year ago
4.3.0
1 year ago