Skip to content

Commit 29c674d

Browse files
authored
Merge 8801515 into 175070c
2 parents 175070c + 8801515 commit 29c674d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/component/src/provider.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,20 @@ describe('Provider', () => {
197197
expect(callback).to.have.been.calledOnce;
198198
});
199199

200+
it('passes service instance', () => {
201+
const serviceInstance = { test: true };
202+
provider.setComponent(getFakeComponent('test', () => serviceInstance));
203+
const callback = fake();
204+
205+
// initialize the service instance
206+
provider.getImmediate();
207+
208+
provider.onInit(callback);
209+
210+
expect(callback).to.have.been.calledOnce;
211+
expect(callback).to.have.been.calledWith(serviceInstance);
212+
});
213+
200214
it('passes instance identifier', () => {
201215
provider.setComponent(
202216
getFakeComponent(

packages/component/src/provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export class Provider<T extends Name> {
272272
existingCallbacks.add(callback);
273273
this.onInitCallbacks.set(normalizedIdentifier, existingCallbacks);
274274

275-
const existingInstance = this.instances.has(normalizedIdentifier);
275+
const existingInstance = this.instances.get(normalizedIdentifier);
276276
if (existingInstance) {
277277
callback(existingInstance, normalizedIdentifier);
278278
}

0 commit comments

Comments
 (0)