Skip to content

Commit

Permalink
stash more tweaks from work with Preston
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Aug 17, 2023
1 parent 9ae30d8 commit 936ffa5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/data-worker/src/-private/worker-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export class WorkerFetch {
declare threadId: string;
declare pending: Map<string, { context: Context; deferred: Deferred }>;

constructor(store: Store) {
constructor(store: Store, workerUrl: Url) {
this.threadId = isServerEnv ? '' : crypto.randomUUID();
this.store = store;
const worker = (this.worker = new SharedWorker('/assets/ember-data-cache-worker.js'));
const worker = (this.worker = new SharedWorker(workerUrl);
worker.port.onmessage = (event: WorkerEvent) => {};
}

Expand Down
7 changes: 6 additions & 1 deletion tests/recommended-json-api/app/services/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import DataStore, { CacheHandler } from '@ember-data/store';
import type { Cache } from '@ember-data/types/cache/cache';
import type { CacheCapabilitiesManager } from '@ember-data/types/q/cache-store-wrapper';
import type { StableRecordIdentifier } from '@ember-data/types/q/identifier';
import { WorkerFetch } from '@ember-data/worker';

import CONFIG from '../config/environment';

Expand All @@ -16,7 +17,11 @@ export default class Store extends DataStore {
super(args);

const manager = (this.requestManager = new RequestManager());
manager.use([Fetch]);
const
const workerFetch = new WorkerFetch(this, workerUrl);
const worker = new Worker(new Url('my-worker', import.meta.url, { type: 'module'})
))
manager.use([workerFetch, Fetch]);
manager.useCache(CacheHandler);

this.registerSchema(buildSchema(this));
Expand Down
4 changes: 2 additions & 2 deletions tests/recommended-json-api/workers/ember-data-cache-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { CacheCapabilitiesManager } from '@ember-data/types/q/cache-store-w

const CONFIG = {
apiCacheHardExpires: 120_000, // 2 minutes
apiCacheSoftExpires: 30_000, // 30 seconds
apiCacheSoftExworkpires: 30_000, // 30 seconds
};

class Store extends DataStore {
Expand Down Expand Up @@ -44,4 +44,4 @@ class Store extends DataStore {
}
}

export default new DataWorker(Store);
export default DataWorke.create(Store);

0 comments on commit 936ffa5

Please sign in to comment.