Fetches a resource by URL and adds it to the store.
(
/** The resource URL to be fetched */
subject: string,
opts: {
/**
* Fetch it from the `/path` endpoint of your server URL. This effectively
* is a proxy / cache.
*/
fromProxy?: boolean;
} = {},
)
| 89 | |
| 90 | /** Fetches a resource by URL and adds it to the store. */ |
| 91 | async fetchResource( |
| 92 | /** The resource URL to be fetched */ |
| 93 | subject: string, |
| 94 | opts: { |
| 95 | /** |
| 96 | * Fetch it from the `/path` endpoint of your server URL. This effectively |
| 97 | * is a proxy / cache. |
| 98 | */ |
| 99 | fromProxy?: boolean; |
| 100 | } = {}, |
| 101 | ): Promise<Resource> { |
| 102 | const fetched = await fetchResource( |
| 103 | subject, |
| 104 | this, |
| 105 | opts.fromProxy && this.getServerUrl(), |
| 106 | ); |
| 107 | return fetched; |
| 108 | } |
| 109 | |
| 110 | getAllSubjects(): string[] { |
| 111 | return Array.from(this.resources.keys()); |
no test coverage detected