From 6df12b70900bbeeb4018016d04c2fad543820da4 Mon Sep 17 00:00:00 2001 From: David Idol Date: Thu, 16 Jul 2015 14:24:33 -0700 Subject: [PATCH] Add a "fetchHasChanged" method This allows use of [`toPromise()`](http://martyjs.org/api/stores/index.html#fetch-result-toPromise) when constructing `fetchResult` objects [manually](http://martyjs.org/api/stores/index.html#fetch_pending) inside a store without relying on the store's `this.fetch()`. Very important for unit testing. --- src/store/store.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/store/store.js b/src/store/store.js index 94fd085..78a5608 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -130,6 +130,11 @@ class Store { emitChange(); } } + + fetchHasChanged(fetch) { + let emitter = this.__emitter; + emitter.emit.call(emitter, StoreEvents.FETCH_CHANGE_EVENT, fetch); + } hasAlreadyFetched(fetchId) { return !!this.__fetchHistory[fetchId]; @@ -205,4 +210,4 @@ class Store { Store.prototype.fetch = fetch; Store.prototype.handleAction = handleAction; -module.exports = Store; \ No newline at end of file +module.exports = Store;