Skip to content
This repository has been archived by the owner on Oct 23, 2021. It is now read-only.

sp core library.servicescope.provide

John Nguyen edited this page Apr 22, 2021 · 2 revisions

Home > @microsoft/sp-core-library > ServiceScope > provide

ServiceScope.provide() method

Add a new service to a service scope.

Signature:

provide<T>(serviceKey: ServiceKey<T>, service: T): T;

Parameters

Parameter Type Description
serviceKey ServiceKey<T> the key that will later be used to consume the service
service T the service instance that is being registered

Returns:

T

the same object that was passed as the "service" parameter

Remarks

ServiceScope.provide() is used to register an implementation of the given serviceKey for the current scope. It may only be used when the ServiceScope is in an "unfinished" state, i.e. before finish() has been called.

Clone this wiki locally