Skip to content

Commit

Permalink
auto-init auth-internal after initializing auth (#5071)
Browse files Browse the repository at this point in the history
* auto-init auth-internal after initializing auth

* Create sixty-masks-wash.md
  • Loading branch information
Feiyang1 authored Jun 28, 2021
1 parent 1bbdbfe commit 56a6a9d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/sixty-masks-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@firebase/auth": patch
"@firebase/component": patch
---

Auto initialize `auth-internal` after `auth` has been initialized.
11 changes: 10 additions & 1 deletion packages/auth/src/exports_auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,16 @@ fireauth.exportlib.exportFunction(
'multipleInstances': false,
'serviceProps': namespace,
'instantiationMode': 'LAZY',
'type': 'PUBLIC'
'type': 'PUBLIC',
/**
* Initialize auth-internal after auth is initialized to make auth available to other firebase products.
*/
'onInstanceCreated': function (container, _instanceIdentifier, _instance) {
const authInternalProvider = container['getProvider'](
'auth-internal'
);
authInternalProvider['initialize']();
}
};

// Provides Auth internal APIs.
Expand Down
9 changes: 7 additions & 2 deletions packages/component/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ export class Provider<T extends Name> {
}
}

this.invokeOnInitCallbacks(instance, normalizedIdentifier);

return instance;
}

Expand Down Expand Up @@ -318,6 +316,13 @@ export class Provider<T extends Name> {
});
this.instances.set(instanceIdentifier, instance);

/**
* Invoke onInit listeners.
* Note this.component.onInstanceCreated is different, which is used by the component creator,
* while onInit listeners are registered by consumers of the provider.
*/
this.invokeOnInitCallbacks(instance, instanceIdentifier);

/**
* Order is important
* onInstanceCreated() should be called after this.instances.set(instanceIdentifier, instance); which
Expand Down

0 comments on commit 56a6a9d

Please sign in to comment.