Skip to content

Commit 10b1e5f

Browse files
Set owner on strategies (#441)
1 parent 7346e80 commit 10b1e5f

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/-private/system/ember-orbit-setup.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface FactoryForFolderType {
2222
'/data-buckets/': { default: { create(injections: object): Bucket } };
2323
'/data-models/': { default: ModelFactory };
2424
'/data-sources/': { default: typeof MemorySourceFactory };
25-
'/data-strategies/': { default: { create(): Strategy } };
25+
'/data-strategies/': { default: { create(injections: object): Strategy } };
2626
}
2727

2828
function registerDataBuckets(owner: Owner, modules: Record<string, unknown>) {
@@ -79,17 +79,24 @@ function registerDataSources(owner: Owner, modules: Record<string, unknown>) {
7979
}
8080
}
8181

82-
function registerDataStrategies(modules: Record<string, unknown>) {
82+
function registerDataStrategies(
83+
owner: Owner,
84+
modules: Record<string, unknown>,
85+
) {
8386
const folder = '/data-strategies/';
8487
const registry = orbitRegistry.registrations.strategies;
8588

8689
for (const [key, module] of Object.entries(modules)) {
8790
let [, name] = key.split(folder);
8891
name = getName(name as string);
8992

93+
const strategySettings = {};
94+
95+
setOwner(strategySettings, owner);
96+
9097
registry[name] = (
9198
module as FactoryForFolderType['/data-strategies/']
92-
).default?.create?.();
99+
).default?.create?.(strategySettings);
93100
}
94101
}
95102

@@ -146,11 +153,13 @@ function registerModules(owner: Owner, modules: Record<string, unknown>) {
146153
registerInjectableServices(owner);
147154
// Then register the sources themselves
148155
registerDataSources(owner, sourceModules);
149-
registerDataStrategies(strategyModules);
156+
registerDataStrategies(owner, strategyModules);
157+
158+
const storeSourceSettings = {} as MemorySourceSettings;
159+
setOwner(storeSourceSettings, owner);
150160
// Register the store source after registering all modules
151-
orbitRegistry.registrations.sources['store'] = DataSourceStore.create(
152-
{} as MemorySourceSettings,
153-
);
161+
orbitRegistry.registrations.sources['store'] =
162+
DataSourceStore.create(storeSourceSettings);
154163
const storeSettings = {} as StoreSettings;
155164
setOwner(storeSettings, owner);
156165
orbitRegistry.services.store = StoreService.create(storeSettings);

0 commit comments

Comments
 (0)