radiomanifest.js 698 B

1234567891011121314151617181920212223242526272829
  1. import radiomanifest from "@radiomanifest/radiomanifest";
  2. const knownRadios = ["https://www.ondarossa.info", "https://radiospore.oziosi.org"]
  3. class Controller {
  4. constructor() {
  5. this.cache = {}
  6. this.currentRadio = null
  7. for(let r in knownRadios) {
  8. this.get(r);
  9. }
  10. }
  11. async get(url) {
  12. if(this.cache[url]) {
  13. this.currentRadio = this.cache[url];
  14. return this.cache[url];
  15. }
  16. this.cache[url] = knownRadios[url];
  17. // fetch more data in background
  18. this.cache[url] = await radiomanifest.get(url)
  19. return this.cache[url]
  20. }
  21. }
  22. const ControllerSingleton = new Controller();
  23. // console.log(ControllerSingleton);
  24. export default ControllerSingleton;