From 95dc5da201d4a5370924593273d9cfccd1f35261 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 5 Jul 2018 10:17:56 -0700 Subject: [PATCH] Add an env var to toggle blockingQueries support Mostly helpful when working with mirage --- ui/app/utils/properties/watch.js | 9 ++++++--- ui/config/environment.js | 3 +-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ui/app/utils/properties/watch.js b/ui/app/utils/properties/watch.js index a372d293d..aec2c6921 100644 --- a/ui/app/utils/properties/watch.js +++ b/ui/app/utils/properties/watch.js @@ -3,13 +3,16 @@ import { get } from '@ember/object'; import RSVP from 'rsvp'; import { task } from 'ember-concurrency'; import wait from 'nomad-ui/utils/wait'; +import config from 'nomad-ui/config/environment'; + +const isEnabled = config.APP.blockingQueries !== false; export function watchRecord(modelName) { return task(function*(id, throttle = 2000) { if (typeof id === 'object') { id = get(id, 'id'); } - while (!Ember.testing) { + while (isEnabled && !Ember.testing) { try { yield RSVP.all([ this.get('store').findRecord(modelName, id, { @@ -32,7 +35,7 @@ export function watchRecord(modelName) { export function watchRelationship(relationshipName) { return task(function*(model, throttle = 2000) { - while (!Ember.testing) { + while (isEnabled && !Ember.testing) { try { yield RSVP.all([ this.get('store') @@ -54,7 +57,7 @@ export function watchRelationship(relationshipName) { export function watchAll(modelName) { return task(function*(throttle = 2000) { - while (!Ember.testing) { + while (isEnabled && !Ember.testing) { try { yield RSVP.all([ this.get('store').findAll(modelName, { reload: true, adapterOptions: { watch: true } }), diff --git a/ui/config/environment.js b/ui/config/environment.js index fdceb4472..b97c3f183 100644 --- a/ui/config/environment.js +++ b/ui/config/environment.js @@ -19,8 +19,7 @@ module.exports = function(environment) { }, APP: { - // Here you can pass flags/options to your application instance - // when it is created + blockingQueries: true, }, };