mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-20 10:12:01 +01:00
65be52ed3d
* ADD: Wallet Details screen * FIX: Fixed receive and send calls * FIX: improve splash image and colors * FIX: Modified Encrypted Storage prompt to avoid cancellation * FIX: improved tx refresh strategy * FIX: HDBread tx confirmations calculation
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
function EV(eventName, arg) {
|
|
if (Object.values(EV.enum).indexOf(eventName) === -1) {
|
|
return console.warn('Unregistered event', eventName, 'registered events:', EV.enum);
|
|
}
|
|
EV.callbacks = EV.callbacks || {}; // static variable
|
|
EV.callbacks[eventName] = EV.callbacks[eventName] || [];
|
|
|
|
if (typeof arg !== 'function') {
|
|
// then its an argument
|
|
console.log('got event', eventName, '...');
|
|
for (let cc of EV.callbacks[eventName]) {
|
|
console.log('dispatching event', eventName);
|
|
cc(arg);
|
|
}
|
|
} else {
|
|
// its a callback. subscribe it to event
|
|
console.log('someone subscribed to', eventName);
|
|
EV.callbacks[eventName].push(arg);
|
|
}
|
|
}
|
|
|
|
EV.enum = {
|
|
// emitted when local wallet created or deleted, so one must redraw wallets carousel
|
|
WALLETS_COUNT_CHANGED: 'WALLETS_COUNT_CHANGED',
|
|
|
|
// emitted when local wallet (usually current wallet) has changed number of transactions
|
|
// so one must redraw main screen transactions list and WalletTransactions screen tx list
|
|
TRANSACTIONS_COUNT_CHANGED: 'TRANSACTIONS_COUNT_CHANGED',
|
|
|
|
// emitted when we know for sure that on remote server tx list
|
|
// changed (usually for current wallet)
|
|
REMOTE_TRANSACTIONS_COUNT_CHANGED: 'REMOTE_TRANSACTIONS_COUNT_CHANGED',
|
|
|
|
CREATE_TRANSACTION_NEW_DESTINATION_ADDRESS: 'CREATE_TRANSACTION_NEW_DESTINATION_ADDRESS',
|
|
|
|
// RECEIVE_ADDRESS_CHANGED: 'RECEIVE_ADDRESS_CHANGED',
|
|
};
|
|
|
|
module.exports = EV;
|