component_container.d.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * @license
  3. * Copyright 2019 Google LLC
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import { Provider } from './provider';
  18. import { Component } from './component';
  19. import { Name } from './types';
  20. /**
  21. * ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
  22. */
  23. export declare class ComponentContainer {
  24. private readonly name;
  25. private readonly providers;
  26. constructor(name: string);
  27. /**
  28. *
  29. * @param component Component being added
  30. * @param overwrite When a component with the same name has already been registered,
  31. * if overwrite is true: overwrite the existing component with the new component and create a new
  32. * provider with the new component. It can be useful in tests where you want to use different mocks
  33. * for different tests.
  34. * if overwrite is false: throw an exception
  35. */
  36. addComponent<T extends Name>(component: Component<T>): void;
  37. addOrOverwriteComponent<T extends Name>(component: Component<T>): void;
  38. /**
  39. * getProvider provides a type safe interface where it can only be called with a field name
  40. * present in NameServiceMapping interface.
  41. *
  42. * Firebase SDKs providing services should extend NameServiceMapping interface to register
  43. * themselves.
  44. */
  45. getProvider<T extends Name>(name: T): Provider<T>;
  46. getProviders(): Array<Provider<Name>>;
  47. }