value: function (typeOrQuery) { var type = typeOrQuery instanceof ObjectDescriptor && typeOrQuery, query = type && DataQuery.withTypeAndCriteria(type) || typeOrQuery, stream = new this(); stream.query = query; return stream; }
value: function (type, object, propertyName, prerequisitePropertyNames, criteria) { var self, selector, prerequisites, stream; // Create and cache a new fetch promise if necessary. if (!this._getCachedFetchPromise(object, propertyName)) { // Parse arguments. if (arguments.length >= 4) { selector = DataQuery.withTypeAndCriteria(type, arguments[arguments.length - 1]);//RDW unclear if there's any special change required here for formal Criteria } else { selector = DataQuery.withTypeAndCriteria(type); } if (arguments.length < 5 || !prerequisitePropertyNames) { prerequisites = []; } else if (!Array.isArray(prerequisitePropertyNames)) { prerequisites = Array.prototype.slice.call(arguments, 3, -1); } else { prerequisites = prerequisitePropertyNames; } // Create and cache a new fetch promise self = this; this._setCachedFetchPromise(object, propertyName, this.nullPromise.then(function () { // First get prerequisite data if necessary... return self.rootService.getObjectProperties(object, prerequisites); }).then(function () { // Then fetch the requested data... stream = self.rootService.fetchData(selector); return stream; }).then(function () { // Then wait until the next event loop to ensure only one // fetch is dispatched per event loop (caching ensures all // subsequent requests for the same fetch promise within the // same event loop will return the same promise)... return self.eventLoopPromise; }).then(function () { // Then removes the promise from the cache so subsequent // requests for this fetch promise generate new fetches. self._setCachedFetchPromise(object, propertyName, null); return stream.data; })); } // Return the created or cached fetch promise. return this._getCachedFetchPromise(object, propertyName); }