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 31ee4d1 commit 4523e21
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/response/ModelResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,34 @@ ModelResponse.prototype.mixin = function mixin() {
});
};

/**
* Converts the data format of the data in a JSONGraph Model response to a stream of path values.
* @name toPathValues
* @memberof ModelResponse.prototype
* @function
* @return ModelResponse.<PathValue>
* @example
var model = new falcor.Model({
cache: {
user: {
name: "Steve",
surname: "McGuire"
}
}
});
model.
get(["user",["name", "surname"]]).
toPathValues().
// this method will be called twice, once with the result of ["user", "name"]
// and once with the result of ["user", "surname"]
subscribe(function(pathValue){
console.log(JSON.stringify(pathValue));
});
// prints...
"{\"path\":[\"user\",\"name\"],\"value\":\"Steve\"}"
"{\"path\":[\"user\",\"surname\"],\"value\":\"McGuire\"}"
*/
ModelResponse.prototype.toPathValues = function toPathValues() {
return this.mixin(valuesMixin).asObservable();
};
Expand Down

0 comments on commit 4523e21

Please sign in to comment.