diff --git a/wiki/container_api.md b/wiki/container_api.md index 251861e8..105d985b 100644 --- a/wiki/container_api.md +++ b/wiki/container_api.md @@ -127,6 +127,7 @@ An advanced feature that can be used for cross cutting concerns. See [middleware ## container.createChild(containerOptions?: interfaces.ContainerOptions): Container; Create a [container hierarchy ](https://github.com/inversify/InversifyJS/blob/master/wiki/hierarchical_di.md). If you do not provide options the child receives the options of the parent. + ## container.get\(serviceIdentifier: interfaces.ServiceIdentifier\): T Resolves a dependency by its runtime identifier. The runtime identifier must be associated with only one binding and the binding must be synchronously resolved, otherwise an error is thrown: @@ -585,6 +586,55 @@ Restore container state to last snapshot. ## container.snapshot(): void Save the state of the container to be later restored with the restore method. + +## container.tryGet\(serviceIdentifier: interfaces.ServiceIdentifier\): T | undefined + +Same as `container.get`, but returns `undefined` in the event no bindings are bound to `serviceIdentifier`. + +## container.tryGetAsync\(serviceIdentifier: interfaces.ServiceIdentifier\): Promise + +Same as `container.getAsync`, but returns `Promise` in the event no bindings are bound to `serviceIdentifier`. + +## container.tryGetNamed\(serviceIdentifier: interfaces.ServiceIdentifier\, named: string | number | symbol): T | undefined + +Same as `container.getNamed`, but returns `undefined` in the event no bindings are bound to `serviceIdentifier`. + +## container.tryGetNamedAsync\(serviceIdentifier: interfaces.ServiceIdentifier\, named: string | number | symbol): Promise\ + +Same as `container.getNamedAsync`, but returns `Promise` in the event no bindings are bound to `serviceIdentifier`. + +## container.tryGetTagged\(serviceIdentifier: interfaces.ServiceIdentifier\, key: string | number | symbol, value: unknown): T | undefined + +Same as `container.getTagged`, but returns `undefined` in the event no bindings are bound to `serviceIdentifier`. + +## container.tryGetTaggedAsync\(serviceIdentifier: interfaces.ServiceIdentifier\, key: string | number | symbol, value: unknown): Promise\ + +Same as `container.getTaggedAsync`, but returns `Promise` in the event no bindings are bound to `serviceIdentifier`. + +## container.tryGetAll\(serviceIdentifier: interfaces.ServiceIdentifier\, options?: interfaces.GetAllOptions): T[] + +Same as `container.getAll`, but returns `[]` in the event no bindings are bound to `serviceIdentifier`. + +## container.tryGetAllAsync\(serviceIdentifier: interfaces.ServiceIdentifier\, options?: interfaces.GetAllOptions): Promise\ + +Same as `container.getAllAsync`, but returns `Promise<[]>` in the event no bindings are bound to `serviceIdentifier`. + +## container.tryGetAllNamed\(serviceIdentifier: interfaces.ServiceIdentifier\, named: string | number | symbol): T[] + +Same as `container.getAllNamed`, but returns `[]` in the event no bindings are bound to `serviceIdentifier`. + +## container.tryGetAllNamedAsync\(serviceIdentifier: interfaces.ServiceIdentifier\, named: string | number | symbol): Promise\ + +Same as `container.getAllNamedAsync`, but returns `Promise<[]>` in the event no bindings are bound to `serviceIdentifier`. + +## container.tryGetAllTagged\(serviceIdentifier: interfaces.ServiceIdentifier\, key: string | number | symbol, value: unknown): T[] + +Same as `container.getAllTagged`, but returns `[]` in the event no bindings are bound to `serviceIdentifier`. + +## container.tryGetAllTaggedAsync\(serviceIdentifier: interfaces.ServiceIdentifier\, key: string | number | symbol, value: unknown): Promise\ + +Same as `container.getAllTaggedAsync`, but returns `Promise<[]>` in the event no bindings are bound to `serviceIdentifier`. + ## container.unbind(serviceIdentifier: interfaces.ServiceIdentifier\): void Remove all bindings binded in this container to the service identifier. This will result in the [deactivation process](https://github.com/inversify/InversifyJS/blob/master/wiki/deactivation_handler.md).