Merge pull request #5764 from BlueWallet/ts

REF: JS modules to TS
This commit is contained in:
GLaDOS 2023-10-23 22:24:31 +01:00 committed by GitHub
commit 849dc4bbe3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 20 deletions

View file

@ -1,4 +1,4 @@
import {NativeModules} from 'react-native';
import { NativeModules } from 'react-native';
// Mock the ImagePickerManager native module to allow us to unit test the JavaScript code
NativeModules.ImagePickerManager = {

View file

@ -1,5 +0,0 @@
/**
* Let's keep config vars, constants and definitions here
*/
export const groundControlUri = 'https://groundcontrol-bluewallet.herokuapp.com/';

View file

@ -0,0 +1,5 @@
/**
* Let's keep config vars, constants and definitions here
*/
export const groundControlUri: string = 'https://groundcontrol-bluewallet.herokuapp.com/';

View file

@ -1,14 +0,0 @@
// https://levelup.gitconnected.com/debounce-in-javascript-improve-your-applications-performance-5b01855e086
const debounce = (func, wait) => {
let timeout;
return function executedFunction(...args) {
const later = () => {
timeout = null;
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
};
export default debounce;

16
blue_modules/debounce.ts Normal file
View file

@ -0,0 +1,16 @@
// https://levelup.gitconnected.com/debounce-in-javascript-improve-your-applications-performance-5b01855e086
const debounce = <T extends (...args: any[]) => void>(func: T, wait: number) => {
let timeout: NodeJS.Timeout | null;
return function executedFunction(this: ThisParameterType<T>, ...args: Parameters<T>) {
const later = () => {
timeout = null;
func.apply(this, args);
};
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(later, wait);
};
};
export default debounce;