/**
 * Copyright (c) 2021 BlockDev AG
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */ import { ipcRenderer } from "electron" ; import _ from "lodash" ; import { MainIpcListenChannels } from "../../shared/ipc" ; const memoizedDebounced = function ( func , wait = 0 , options = { } ) { const mem = _ . memoize ( function ( param ) { return _ . debounce ( func , wait , options ) ; } ) ; return function ( param ) { mem ( param ) ( param ) ; } ; } ; export const subscribePush = ( topic ) : void => memoizedDebounced ( ( t ) => { ipcRenderer . send ( MainIpcListenChannels . PushSubscribe , t ) ; } , 60 * 60000 , { leading : true } ) ( topic ) ; export const unsubscribePush = ( topic ) : void => memoizedDebounced ( ( t ) => { ipcRenderer . send ( MainIpcListenChannels . PushUnsubscribe , t ) ; } , 60 * 60000 , { leading : true } ) ( topic ) ;