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

sp core library.servicescope.finish

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

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

ServiceScope.finish() method

Completes the initialization sequence for a service scope.

Signature:

finish(): void;

Returns:

void

Remarks

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.

Clone this wiki locally