Skip to content

Commit

Permalink
Update ModelResponse.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jhusain committed Aug 9, 2015
1 parent 0c38886 commit 31ee4d1
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions lib/response/ModelResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,63 @@ ModelResponse.prototype.toJSONG = function toJSONG() {
return this.mixin(jsongMixin);
};

/**
* The progressively method breaks the response up into two parts: the data immediately available in the Model cache, and the data in the Model cache after the missing data has been retrieved from the DataSource.
* The progressively method creates a ModelResponse that immediately returns the requested data that is available in the Model cache. If any requested paths are not available in the cache, the ModelResponse will send another JSON message with all of the requested data after it has been retrieved from the DataSource.
* @name progressively
* @memberof ModelResponse.prototype
* @function
* @return {ModelResponse.<JSONEnvelope>} the values found at the requested paths.
* @example
var dataSource = (new falcor.Model({
cache: {
user: {
name: "Steve",
surname: "McGuire",
age: 31
}
}
})).asDataSource();
var model = new falcor.Model({
source: dataSource,
cache: {
user: {
name: "Steve",
surname: "McGuire"
}
}
});
model.
get(["user",["name", "surname", "age"]]).
progressively().
// this callback will be invoked twice, once with the data in the
// Model cache, and again with the additional data retrieved from the DataSource.
subscribe(function(json){
console.log(JSON.stringify(json,null,4));
});
// prints...
// {
// "json": {
// "user": {
// "name": "Steve",
// "surname": "McGuire"
// }
// }
// }
// ...and then prints...
// {
// "json": {
// "user": {
// "name": "Steve",
// "surname": "McGuire",
// "age": 31
// }
// }
// }
*/
ModelResponse.prototype.progressively = function progressively() {
return this.mixin(progressiveMixin);
};
Expand Down

0 comments on commit 31ee4d1

Please sign in to comment.