[]previous and next page

resourceKey

Returns the key a resource's value is stored under in the server data, the same on the server and the client: the explicit key when there is one, else one drawn from the current scope.

Returns the key a resource's value is stored under in the server data, the same on the server and the client: the explicit key when there is one, else one drawn from the current scope.

Import#

ts
import { resourceKey } from "@shadow-js/web/extend";

Signature#

ts
function resourceKey(explicit: string | undefined): string

Parameters#

Name Description
explicit The resource's own key. When given, the result is `k:${explicit}`, a prefix no generated key has. Undefined draws the next resource key of the scope.

Returns#

`k:${explicit}`; otherwise the scope id, r and the creation index ("0-1-r0"); "r" outside a scope.

Examples#

ts
import { createRootScope, resourceKey, withScope } from "@shadow-js/web/extend";

withScope(createRootScope(), () => [resourceKey(undefined), resourceKey("user")]);
// ["0-r0", "k:user"]