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

sp core library.servicekey.create

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

Home > @microsoft/sp-core-library > ServiceKey > create

ServiceKey.create() method

Constructs a new ServiceKey whose default implementation will be a new instance of a TypeScript class that accepts the standard constructor parameter.

Signature:

static create<TKey>(name: string, serviceClass: {
        new (serviceScope: ServiceScope): TKey;
    }): ServiceKey<TKey>;

Parameters

Parameter Type Description
name string A name such as "my-package.IMyService" which should be unique across packages.
serviceClass { new (serviceScope: ServiceScope): TKey; } the TypeScript class that implements the service.

Returns:

ServiceKey<TKey>

the newly created ServiceKey

Remarks

If you want to specify custom constructor parameters, use ServiceKey.createCustom() instead.

Clone this wiki locally