radiomanifest.js 630 B

12345678910111213141516171819202122232425262728
  1. import radiomanifest from "@radiomanifest/radiomanifest";
  2. class Controller {
  3. constructor() {
  4. this.cache = {};
  5. this.currentRadio = null;
  6. }
  7. getFromCache(url) {
  8. console.log("cache", Object.keys(this.cache));
  9. if (this.cache[url]) {
  10. this.currentRadio = this.cache[url];
  11. return this.cache[url];
  12. }
  13. }
  14. async get(url) {
  15. if (this.cache[url]) {
  16. this.currentRadio = this.cache[url];
  17. return this.cache[url];
  18. }
  19. this.cache[url] = await radiomanifest.get(url);
  20. return this.cache[url];
  21. }
  22. }
  23. const ControllerSingleton = new Controller();
  24. export default ControllerSingleton;