diff options
author | alexwl <alexey.a.kiryushin@gmail.com> | 2019-02-20 18:58:57 +0300 |
---|---|---|
committer | alexwl <alexey.a.kiryushin@gmail.com> | 2019-02-20 18:58:57 +0300 |
commit | eddf2c825dee199de0e958857f0daf3d08a07532 (patch) | |
tree | a2901b6273012308fb0b40a34c4610536a1da9e5 /javascript/app/services | |
parent | c831f86d259b6d949b0f71b894c7f2b07b4eed15 (diff) |
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.
Diffstat (limited to 'javascript/app/services')
-rw-r--r-- | javascript/app/services/store.js | 16 |
1 files changed, 15 insertions, 1 deletions
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; + }); + } + } }); |