From 9e8cfe4191ed80fd16ac39e8c3bab5bd12b198fe Mon Sep 17 00:00:00 2001 From: Frederic Charette Date: Thu, 16 Dec 2021 15:03:26 -0500 Subject: [PATCH] allowing non-promise resolvers --- src/buffer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/buffer.js b/src/buffer.js index 40f830c..80cf651 100644 --- a/src/buffer.js +++ b/src/buffer.js @@ -37,8 +37,8 @@ function queryBuffer(config, emitter, targetStore) { this.state = 1; clearTimeout(this.timer); emitter.emit('query', { cause, key: this.contextKey, uid: this.uid, size: this.ids.length, params: this.params, contexts: this.contexts, ids: this.ids }); - config.resolver(this.ids, this.params, this.contexts) - .then(this.handleQuerySuccess.bind(this), this.handleQueryError.bind(this)); + const request = config.resolver(this.ids, this.params, this.contexts); + (request instanceof Promise ? request : Promise.resolve(request)).then(this.handleQuerySuccess.bind(this), this.handleQueryError.bind(this)); if (numCached > 0) { emitter.emit('cacheHit', numCached);