30 lines
889 B
TypeScript
30 lines
889 B
TypeScript
let createWalletEvents = () => ({
|
|
events: {},
|
|
emit (event, ...args) {
|
|
for (let i of this.events[event] || []) {
|
|
i(...args)
|
|
}
|
|
},
|
|
on (event, cb) {
|
|
;(this.events[event] = this.events[event] || []).push(cb)
|
|
return () => (this.events[event] = this.events[event].filter(i => i !== cb))
|
|
},
|
|
listen(event, cb) {
|
|
;(this.events[event] = this.events[event] || []).push(cb)
|
|
return () => (this.events[event] = this.events[event].filter(i => i !== cb))
|
|
}
|
|
})
|
|
|
|
export { createWalletEvents }
|
|
|
|
export const WALLET_CHAIN_CHANGE = 'wallet_chain_change'
|
|
|
|
export const WALLET_ACCOUNT_CHANGE = 'wallet_account_change'
|
|
|
|
export const WALLET_TOKEN_TYPE_CHANGE = 'wallet_token_type_change'
|
|
|
|
export const WALLET_SHOW_QR = 'wallet_show_qr'
|
|
|
|
export const WALLET_SHOW_ACCOUNT_LIST = 'wallet_show_account_list'
|
|
|
|
export const WALLET_HIDE_ACCOUNT_LIST = 'wallet_hide_account_list' |