-
Notifications
You must be signed in to change notification settings - Fork 5
sp core library.servicescope.finish
Home > @microsoft/sp-core-library > ServiceScope > finish
Completes the initialization sequence for a service scope.
Signature:
finish(): void;
Returns:
void
When a ServiceScope is first started, it is in an "unfinished" state where provide() is allowed but consume() is disallowed. After calling finish(), then consume() is allowed but provide() is disallowed.
This formalism prevents a number of complex situations that could lead to bugs. For example, supposed that Scope2 is a child of Scope1, and Scope1 provides instance A1 of interface A. If someone consumes A1 from Scope2 (via inheritance) before Scope2.provide() is called with A2, then a subsequent call to Scope2.consume() might return a different result than the previous call. This nondeterminism could cause unpredictable results that are difficult to diagnose.