const container = Container
.providesValue("values", [1]) // Initially provide an array with one value
.provides(ConcatInjectable("values", () => 2)); // Append another value to the array
const result = container.get("values"); // Results in [1, 2]
In this context, ConcatInjectable("values", () => 2)
acts as a simplified form of
Injectable("values", ["values"], (values: number[]) => [...values, 2])
,
directly appending a new value to the "values" service array without the need for explicit array manipulation.
Creates an Injectable factory function with dependencies that appends a Service to an existing array of Services of the same type. This variant supports services that require other services to be instantiated, allowing for more complex setups.
Token identifying an existing Service array to append the new Service to.
Read-only list of Tokens for dependencies required by the factory function.
Factory function returning the Service to append. The types and number of its parameters must exactly match the dependencies.
Creates an Injectable factory function without dependencies that appends a Service to an existing array of Services of the same type. Useful for dynamically expanding service collections without altering original service tokens or factories.