From eddf2c825dee199de0e958857f0daf3d08a07532 Mon Sep 17 00:00:00 2001 From: alexwl Date: Wed, 20 Feb 2019 18:58:57 +0300 Subject: Adds an option to use public Hoogle JSON API (https://github.com/ndmitchell/hoogle/blob/3dbf68bfd701f942d3af2e6debb74a0a78cd392e/docs/API.md#json-api) to get documentation for not indexed packages. Closes #21. --- javascript/app/services/store.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'javascript/app/services') diff --git a/javascript/app/services/store.js b/javascript/app/services/store.js index 8001061..650ddcf 100644 --- a/javascript/app/services/store.js +++ b/javascript/app/services/store.js @@ -53,6 +53,7 @@ export default Ember.Service.extend({ this.expressions = {}; this.references = {}; this.globalReferences = {}; + this.hoogleDocs = {}; }, loadPackage(packageId) { const packageInfo = this.packages[packageId]; @@ -144,11 +145,24 @@ export default Ember.Service.extend({ if(globalReferences) { return new RSVP.Promise((resolve) => {resolve(globalReferences);}); } else { - const url = urls.globalReferencesUrl(externalId); + const url = urls.globalReferencesUrl(externalId); return Ember.$.getJSON(url).then((refs) => { this.globalReferences[externalId] = refs; return refs; }); } }, + loadHoogleDocs(packageId,moduleName,entity,name) { + const id = packageId + "/" + moduleName + "/" + entity + "/" + name; + const hoogleDoc = this.hoogleDocs[id]; + if(hoogleDoc) { + return new RSVP.Promise((resolve)=>{resolve(hoogleDoc);}); + } else { + const url = urls.hoogleDocsUrl(packageId,moduleName,entity,name); + return Ember.$.getJSON(url).then((hoogleDoc) => { + this.hoogleDocs[id] = hoogleDoc; + return hoogleDoc; + }); + } + } }); -- cgit v1.2.3