Skip to content

Instantly share code, notes, and snippets.

@ferclaverino
Created July 26, 2012 21:26
Show Gist options
  • Save ferclaverino/3184637 to your computer and use it in GitHub Desktop.
Save ferclaverino/3184637 to your computer and use it in GitHub Desktop.
query object
(function () {
"use strict";
var feedNewsMapper;
// constructor function
function init() {
feedNewsMapper = new Mappers.FeedNewsMapper;
}
var instanceMembers = {
getNews: function (section) {
var timeSpan = new Date().getTime();
return WinJS.xhr({
url: ApplicationConfiguration.getServiceRootSite() + section + "?c=500&t=" + timeSpan
}).then(function (response) {
var feedNews = JSON.parse(response.responseText);
// map news to model
var news = feedNewsMapper.mapNewsToModel(feedNews, section)
return WinJS.Promise.wrap(news);
});
}
};
var staticMembers = {};
var NewsBySectionQuery = WinJS.Class.define(init, instanceMembers, staticMembers);
// add to namespace
WinJS.Namespace.define("Queries",
{
NewsBySectionQuery: NewsBySectionQuery
}
);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment