sp core library.servicescope.createandprovide - microsoft/Viva-Connections-Extensibility-Beta GitHub Wiki
Home > @microsoft/sp-core-library > ServiceScope > createAndProvide
This is a shorthand function that is equivalent to constructing a new instance of the simpleServiceClass, then registering it by calling ServiceScope.provide().
Signature:
createAndProvide<T>(serviceKey: ServiceKey<T>, simpleServiceClass: {
new (serviceScope: ServiceScope): T;
}): T;| Parameter | Type | Description |
|---|---|---|
| serviceKey | ServiceKey<T> | the key that can be used later to consume the service |
| simpleServiceClass | { new (serviceScope: ServiceScope): T; } | the TypeScript class to be constructed |
Returns:
T
a newly constructed instance of simpleServiceClass