From 497dba418d2a593d3315708e02ae5453b6364e07 Mon Sep 17 00:00:00 2001 From: vignesh-ph Date: Tue, 13 Jun 2023 15:48:08 +0530 Subject: [PATCH] feat: functions to be called after the application has been painted --- lib/application/index.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/application/index.js b/lib/application/index.js index 5a95a59..1eb51b5 100644 --- a/lib/application/index.js +++ b/lib/application/index.js @@ -57,6 +57,7 @@ function Application (config) { this._readyQueue = []; this._renderQueue = []; this._configQueue = []; + this._paintsQueue = []; this._promise = new Promise(function (resolve, reject) { this._resolve = resolve; this._reject = reject; @@ -164,6 +165,22 @@ Application.prototype.processConfig = function (fn) { this.configure = this._configQueue.push = fn; }; +/** + * @param {Function} fn Function that can be queued to be executed + */ + +Application.prototype.queuePaintFunctions = function(fn) { + this._paintsQueue.push(fn); +} + +/** + * To be called by application after the interface has been painted + */ + +Application.prototype.processQueuedPaintFunctions = function() { + this._paintsQueue.forEach((fn) => fn()) +} + // -------------------------------------------------------------------------- // Exports class definition. // --------------------------------------------------------------------------