From 9526207af876358987d7f0570f2e700418554b83 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 4 Mar 2016 11:13:31 -0800 Subject: [PATCH] [Build] Replace setTimeout with To avoid need to declare global usage to satisfy JSHint --- platform/search/bundle.js | 1 + platform/search/src/services/GenericSearchProvider.js | 10 ++++++---- .../search/test/services/GenericSearchProviderSpec.js | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/platform/search/bundle.js b/platform/search/bundle.js index fb5714fab6..74040b84f4 100644 --- a/platform/search/bundle.js +++ b/platform/search/bundle.js @@ -103,6 +103,7 @@ define([ "type": "provider", "implementation": GenericSearchProvider, "depends": [ + "$timeout", "$q", "$log", "modelService", diff --git a/platform/search/src/services/GenericSearchProvider.js b/platform/search/src/services/GenericSearchProvider.js index 7eff7c3b08..caa5dec428 100644 --- a/platform/search/src/services/GenericSearchProvider.js +++ b/platform/search/src/services/GenericSearchProvider.js @@ -41,8 +41,9 @@ define([ * @param {TopicService} topic the topic service. * @param {Array} ROOTS An array of object Ids to begin indexing. */ - function GenericSearchProvider($q, $log, modelService, workerService, topic, ROOTS) { + function GenericSearchProvider($timeout, $q, $log, modelService, workerService, topic, ROOTS) { var provider = this; + this.$timeout = $timeout; this.$q = $q; this.$log = $log; this.modelService = modelService; @@ -188,7 +189,8 @@ define([ */ GenericSearchProvider.prototype.beginIndexRequest = function () { var idToIndex = this.idsToIndex.shift(), - provider = this; + provider = this, + $timeout = this.$timeout; this.pendingRequests += 1; this.modelService @@ -204,10 +206,10 @@ define([ .warn('Failed to index domain object ' + idToIndex); }) .then(function () { - setTimeout(function () { + $timeout(function () { provider.pendingRequests -= 1; provider.keepIndexing(); - }, 0); + }, 0, false); }); }; diff --git a/platform/search/test/services/GenericSearchProviderSpec.js b/platform/search/test/services/GenericSearchProviderSpec.js index da3f43897f..b7c8321add 100644 --- a/platform/search/test/services/GenericSearchProviderSpec.js +++ b/platform/search/test/services/GenericSearchProviderSpec.js @@ -19,7 +19,6 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ - runs*/ /** * SearchSpec. Created by shale on 07/31/2015. @@ -43,6 +42,7 @@ define([ provider; beforeEach(function () { + $timeout = jasmine.createSpy('$timeout'); $q = jasmine.createSpyObj( '$q', ['defer'] @@ -82,6 +82,7 @@ define([ spyOn(GenericSearchProvider.prototype, 'scheduleForIndexing'); provider = new GenericSearchProvider( + $timeout, $q, $log, modelService,