diff --git a/v2/internal/runtime/js/core/events.js b/v2/internal/runtime/js/core/events.js index 2b373adc..fb190e57 100644 --- a/v2/internal/runtime/js/core/events.js +++ b/v2/internal/runtime/js/core/events.js @@ -154,54 +154,4 @@ export function Emit(eventName) { // Notify Go listeners SendMessage('Ej' + JSON.stringify(payload)); -} - -// Callbacks for the heartbeat calls -const heartbeatCallbacks = {}; - -/** - * Heartbeat emits the event `eventName`, every `timeInMilliseconds` milliseconds until - * the event is acknowledged via `Event.Acknowledge`. Once this happens, `callback` is invoked ONCE - * - * @export - * @param {string} eventName - * @param {number} timeInMilliseconds - * @param {function} callback - */ -export function Heartbeat(eventName, timeInMilliseconds, callback) { - - // Declare interval variable - let interval = null; - - // Setup callback - function dynamicCallback() { - // Kill interval - clearInterval(interval); - // Callback - callback(); - } - - // Register callback - heartbeatCallbacks[eventName] = dynamicCallback; - - // Start emitting the event - interval = setInterval(function () { - Emit(eventName); - }, timeInMilliseconds); -} - -/** - * Acknowledges a heartbeat event by name - * - * @export - * @param {string} eventName - */ -export function Acknowledge(eventName) { - // If we are waiting for acknowledgement for this event type - if (heartbeatCallbacks[eventName]) { - // Acknowledge! - heartbeatCallbacks[eventName](); - } else { - throw new Error(`Cannot acknowledge unknown heartbeat '${eventName}'`); - } -} +} \ No newline at end of file diff --git a/v2/internal/runtime/js/runtime/events.js b/v2/internal/runtime/js/runtime/events.js index 30a23a01..cbf2f948 100644 --- a/v2/internal/runtime/js/runtime/events.js +++ b/v2/internal/runtime/js/runtime/events.js @@ -56,35 +56,9 @@ function Emit(eventName) { return window.wails.Events.Emit.apply(null, args); } - -/** - * Heartbeat emits the event `eventName`, every `timeInMilliseconds` milliseconds until - * the event is acknowledged via `Event.Acknowledge`. Once this happens, `callback` is invoked ONCE - * - * @export - * @param {string} eventName - * @param {number} timeInMilliseconds - * @param {function} callback - */ -function Heartbeat(eventName, timeInMilliseconds, callback) { - window.wails.Events.Heartbeat(eventName, timeInMilliseconds, callback); -} - -/** - * Acknowledges a heartbeat event by name - * - * @export - * @param {string} eventName - */ -function Acknowledge(eventName) { - return window.wails.Events.Acknowledge(eventName); -} - module.exports = { OnMultiple: OnMultiple, On: On, Once: Once, Emit: Emit, - Heartbeat: Heartbeat, - Acknowledge: Acknowledge }; \ No newline at end of file