123456789101112131415161718192021222324252627282930313233343536373839 |
- import radiomanifest from "@radiomanifest/radiomanifest";
- const knownRadios = {
- "https://www.ondarossa.info": {
- "name": "ror"
- },
- "https://radiospore.oziosi.org": {},
- // "https://radiowombat.net": {},
- // "https://test.radiogramma.org": {},
- "https://radioblackout.org": {},
- }
- class Controller {
- constructor() {
- this.cache = {}
- this.currentRadio = null
- for(let r in knownRadios) {
- this.get(r);
- }
- }
- async get(url) {
- if(this.cache[url]) {
- this.currentRadio = this.cache[url];
- return this.cache[url];
- }
- this.cache[url] = knownRadios[url];
- // fetch more data in background
- radiomanifest.get(url).then((rm) => {
- console.log("arrivato", url)
- this.cache[url] = rm
- })
- }
- }
- const ControllerSingleton = new Controller();
- // console.log(ControllerSingleton);
- export default ControllerSingleton;
|