Skip to content

Class: Leaf

Represents the current status of a specific Leaf on a Pod as known by LDO.

Example

const leaf = solidLdoDataset
  .getResource("https://example.com/container/resource.ttl");

Hierarchy

Leaf

Constructors

constructor

new Leaf(uri, context): Leaf

Parameters

Name Type Description
uri LeafUri The uri of the leaf
context SolidLdoDatasetContext SolidLdoDatasetContext for the parent dataset

Returns

Leaf

Overrides

Resource.constructor

Defined in

packages/solid/src/resource/Leaf.ts:79

Properties

absent

Protected absent: undefined | boolean

True if this resource has been fetched but does not exist

Inherited from

Resource.absent

Defined in

packages/solid/src/resource/Resource.ts:95


binaryData

Protected binaryData: undefined | { blob: Blob ; mimeType: string }

The raw binary data if this leaf is a Binary resource

Defined in

packages/solid/src/resource/Leaf.ts:73


context

Protected Readonly context: SolidLdoDatasetContext

The SolidLdoDatasetContext from the Parent Dataset

Inherited from

Resource.context

Defined in

packages/solid/src/resource/Resource.ts:62


didInitialFetch

Protected didInitialFetch: boolean = false

True if this resource has been fetched at least once

Inherited from

Resource.didInitialFetch

Defined in

packages/solid/src/resource/Resource.ts:89


isError

Readonly isError: false

Indicates that this resource is not an error

Defined in

packages/solid/src/resource/Leaf.ts:57


notificationSubscription

Protected notificationSubscription: NotificationSubscription

Handles notification subscriptions

Inherited from

Resource.notificationSubscription

Defined in

packages/solid/src/resource/Resource.ts:113


requester

Protected requester: LeafBatchedRequester

Batched Requester for the Leaf

Overrides

Resource.requester

Defined in

packages/solid/src/resource/Leaf.ts:47


status

status: UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | CreateSuccess | BinaryReadSuccess | DataReadSuccess | AbsentReadSuccess | DeleteSuccess | UpdateSuccess | Unfetched

The status of the last request made for this leaf

Overrides

Resource.status

Defined in

packages/solid/src/resource/Leaf.ts:62


type

Readonly type: "leaf"

Indicates that this resource is a leaf resource

Overrides

Resource.type

Defined in

packages/solid/src/resource/Leaf.ts:52


uri

Readonly uri: LeafUri

The URI of the leaf

Overrides

Resource.uri

Defined in

packages/solid/src/resource/Leaf.ts:41


wacRule

Protected Optional wacRule: WacRule

If a wac rule was fetched, it is cached here

Inherited from

Resource.wacRule

Defined in

packages/solid/src/resource/Resource.ts:107


wacUri

Protected Optional wacUri: LeafUri

If a wac uri is fetched, it is cached here

Inherited from

Resource.wacUri

Defined in

packages/solid/src/resource/Resource.ts:101

Methods

addListener

addListener\<E>(event, listener): this

Type parameters

Name Type
E extends "update" | "notification"

Parameters

Name Type
event E
listener { notification: () => void ; update: () => void }[E]

Returns

this

Inherited from

Resource.addListener

Defined in

node_modules/typed-emitter/index.d.ts:22


createAndOverwrite

createAndOverwrite(): Promise\<ResourceResult\<LeafCreateAndOverwriteResult, Leaf>>

Creates a leaf at this URI and overwrites any that already exists

Returns

Promise\<ResourceResult\<LeafCreateAndOverwriteResult, Leaf>>

LeafCreateAndOverwriteResult

Example

const result = await leaf.createAndOverwrite();
if (!result.isError) {
  // Do something
}

Overrides

Resource.createAndOverwrite

Defined in

packages/solid/src/resource/Leaf.ts:411


createIfAbsent

createIfAbsent(): Promise\<ResourceResult\<LeafCreateIfAbsentResult, Leaf>>

Creates a leaf at this URI if the leaf doesn't already exist

Returns

Promise\<ResourceResult\<LeafCreateIfAbsentResult, Leaf>>

LeafCreateIfAbsentResult

Example

const result = await leaf.createIfAbsent();
if (!result.isError) {
  // Do something
}

Overrides

Resource.createIfAbsent

Defined in

packages/solid/src/resource/Leaf.ts:432


delete

delete(): Promise\<DeleteResult>

Deletes this leaf and all its contents

Returns

Promise\<DeleteResult>

A Delete result for this leaf

const result = await container.leaf();
if (!result.isError) {
  // Do something
}

Defined in

packages/solid/src/resource/Leaf.ts:381


emit

emit\<E>(event, ...args): boolean

Type parameters

Name Type
E extends "update" | "notification"

Parameters

Name Type
event E
...args Parameters\<{ notification: () => void ; update: () => void }[E]>

Returns

boolean

Inherited from

Resource.emit

Defined in

node_modules/typed-emitter/index.d.ts:32


emitThisAndParent

emitThisAndParent(): void

Emits an update event for both this resource and the parent

Returns

void

Inherited from

Resource.emitThisAndParent

Defined in

packages/solid/src/resource/Resource.ts:350


eventNames

eventNames(): (string | symbol)[]

Returns

(string | symbol)[]

Inherited from

Resource.eventNames

Defined in

node_modules/typed-emitter/index.d.ts:34


getBlob

getBlob(): undefined | Blob

If this resource is a binary resource, returns the Blob

Returns

undefined | Blob

The Blob if this resource is a binary resource, undefined otherwise

Example

// Logs "some text."
console.log(leaf.getBlob()?.toString());

Defined in

packages/solid/src/resource/Leaf.ts:156


getMaxListeners

getMaxListeners(): number

Returns

number

Inherited from

Resource.getMaxListeners

Defined in

node_modules/typed-emitter/index.d.ts:39


getMimeType

getMimeType(): undefined | string

If this resource is a binary resource, returns the mime type

Returns

undefined | string

The mime type if this resource is a binary resource, undefined otherwise

Example

// Logs "text/txt"
console.log(leaf.getMimeType());

Defined in

packages/solid/src/resource/Leaf.ts:141


getParentContainer

getParentContainer(): Promise\<Container>

Gets the parent container for this leaf by making a request

Returns

Promise\<Container>

The parent container

Example

const leaf = solidLdoDataset
  .getResource("https://example.com/container/resource.ttl");
const leafParent = await leaf.getParentContainer();
if (!leafParent.isError) {
  // Logs "https://example.com/container/"
  console.log(leafParent.uri);
}

Overrides

Resource.getParentContainer

Defined in

packages/solid/src/resource/Leaf.ts:322


getRootContainer

getRootContainer(): Promise\<Container | CheckRootResultError | NoRootContainerError>

Gets the root container for this leaf.

Returns

Promise\<Container | CheckRootResultError | NoRootContainerError>

The root container for this leaf

Example

Suppose the root container is at https://example.com/

const leaf = ldoSolidDataset
  .getResource("https://example.com/container/resource.ttl");
const rootContainer = await leaf.getRootContainer();
if (!rootContainer.isError) {
  // logs "https://example.com/"
  console.log(rootContainer.uri);
}

Overrides

Resource.getRootContainer

Defined in

packages/solid/src/resource/Leaf.ts:344


getWac

getWac(options?): Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | NotFoundHttpError | GetWacRuleSuccess | WacRuleAbsent>

Retrieves web access control (WAC) rules for this resource

Parameters

Name Type Description
options? Object set the "ignoreCache" field to true to ignore any cached information on WAC rules.
options.ignoreCache boolean -

Returns

Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | NotFoundHttpError | GetWacRuleSuccess | WacRuleAbsent>

WAC Rules results

Example

const resource = ldoSolidDataset
  .getResource("https://example.com/container/resource.ttl");
const wacRulesResult = await resource.getWac();
if (!wacRulesResult.isError) {
  const wacRules = wacRulesResult.wacRule;
  // True if the resource is publicly readable
  console.log(wacRules.public.read);
  // True if authenticated agents can write to the resource
  console.log(wacRules.authenticated.write);
  // True if the given WebId has append access
  console.log(
    wacRules.agent[https://example.com/person1/profile/card#me].append
  );
  // True if the given WebId has control access
  console.log(
    wacRules.agent[https://example.com/person1/profile/card#me].control
  );
}

Inherited from

Resource.getWac

Defined in

packages/solid/src/resource/Resource.ts:635


getWacUri

getWacUri(options?): Promise\<GetWacUriResult>

Retrieves the URI for the web access control (WAC) rules for this resource

Parameters

Name Type Description
options? Object set the "ignoreCache" field to true to ignore any cached information on WAC rules.
options.ignoreCache boolean -

Returns

Promise\<GetWacUriResult>

WAC Rules results

Inherited from

Resource.getWacUri

Defined in

packages/solid/src/resource/Resource.ts:584


handleCreateAndOverwrite

handleCreateAndOverwrite(): Promise\<UnexpectedResourceError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | CreateSuccess>

Helper method that handles the core functions for creating and overwriting a resource

Returns

Promise\<UnexpectedResourceError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | CreateSuccess>

DeleteResult

Inherited from

Resource.handleCreateAndOverwrite

Defined in

packages/solid/src/resource/Resource.ts:494


handleCreateIfAbsent

handleCreateIfAbsent(): Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | CreateSuccess | BinaryReadSuccess | DataReadSuccess | ContainerReadSuccess>

Helper method that handles the core functions for creating a resource if absent

Returns

Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | CreateSuccess | BinaryReadSuccess | DataReadSuccess | ContainerReadSuccess>

DeleteResult

Inherited from

Resource.handleCreateIfAbsent

Defined in

packages/solid/src/resource/Resource.ts:530


handleDelete

handleDelete(): Promise\<DeleteResult>

Helper method that handles the core functions for deleting a resource

Returns

Promise\<DeleteResult>

DeleteResult

Inherited from

Resource.handleDelete

Defined in

packages/solid/src/resource/Resource.ts:442


handleRead

handleRead(): Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | BinaryReadSuccess | DataReadSuccess | ContainerReadSuccess | AbsentReadSuccess>

A helper method that handles the core functions for reading

Returns

Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | BinaryReadSuccess | DataReadSuccess | ContainerReadSuccess | AbsentReadSuccess>

ReadResult

Inherited from

Resource.handleRead

Defined in

packages/solid/src/resource/Resource.ts:380


isAbsent

isAbsent(): undefined | boolean

Is this resource currently absent (it does not exist)

Returns

undefined | boolean

true if the resource is absent, false if not, undefined if unknown

Example

// Logs "undefined"
console.log(resource.isAbsent());
const result = await resource.read();
if (!result.isError) {
  // False if the resource exists, true if it does not
  console.log(resource.isAbsent());
}

Inherited from

Resource.isAbsent

Defined in

packages/solid/src/resource/Resource.ts:302


isBinary

isBinary(): undefined | boolean

Check if this resource is a binary resource

Returns

undefined | boolean

True if this resource is a binary resource, false if not, undefined if unknown

Example

// Logs "undefined"
console.log(leaf.isBinary());
const result = await leaf.read();
if (!result.isError) {
  // Logs "true"
  console.log(leaf.isBinary());
}

Defined in

packages/solid/src/resource/Leaf.ts:176


isCreating

isCreating(): boolean

Checks to see if this resource is being created

Returns

boolean

true if the resource is currently being created

Example

resource.read().then(() => {
  // Logs "false"
  console.log(resource.isCreating())
});
// Logs "true"
console.log(resource.isCreating());

Inherited from

Resource.isCreating

Defined in

packages/solid/src/resource/Resource.ts:166


isDataResource

isDataResource(): undefined | boolean

Check if this resource is a data (RDF) resource

Returns

undefined | boolean

True if this resource is a data resource, false if not, undefined if unknown

Example

// Logs "undefined"
console.log(leaf.isDataResource());
const result = await leaf.read();
if (!result.isError) {
  // Logs "true"
  console.log(leaf.isDataResource());
}

Defined in

packages/solid/src/resource/Leaf.ts:199


isDeleting

isDeleting(): boolean

Checks to see if this resource is being deleted

Returns

boolean

true if the resource is currently being deleted

Example

resource.read().then(() => {
  // Logs "false"
  console.log(resource.isDeleting())
});
// Logs "true"
console.log(resource.isDeleting());

Inherited from

Resource.isDeleting

Defined in

packages/solid/src/resource/Resource.ts:202


isDoingInitialFetch

isDoingInitialFetch(): boolean

Checks to see if this resource is being read for the first time

Returns

boolean

true if the resource is currently being read for the first time

Example

resource.read().then(() => {
  // Logs "false"
  console.log(resource.isDoingInitialFetch())
});
// Logs "true"
console.log(resource.isDoingInitialFetch());

Inherited from

Resource.isDoingInitialFetch

Defined in

packages/solid/src/resource/Resource.ts:220


isFetched

isFetched(): boolean

Check to see if this resource has been fetched

Returns

boolean

true if this resource has been fetched before

Example

// Logs "false"
console.log(resource.isFetched());
const result = await resource.read();
if (!result.isError) {
  // Logs "true"
  console.log(resource.isFetched());
}

Inherited from

Resource.isFetched

Defined in

packages/solid/src/resource/Resource.ts:264


isLoading

isLoading(): boolean

Checks to see if this resource is loading in any way

Returns

boolean

true if the resource is currently loading

Example

resource.read().then(() => {
  // Logs "false"
  console.log(resource.isLoading())
});
// Logs "true"
console.log(resource.isLoading());

Inherited from

Resource.isLoading

Defined in

packages/solid/src/resource/Resource.ts:148


isPresent

isPresent(): undefined | boolean

Is this resource currently present on the Pod

Returns

undefined | boolean

false if the resource is absent, true if not, undefined if unknown

Example

// Logs "undefined"
console.log(resource.isPresent());
const result = await resource.read();
if (!result.isError) {
  // True if the resource exists, false if it does not
  console.log(resource.isPresent());
}

Inherited from

Resource.isPresent

Defined in

packages/solid/src/resource/Resource.ts:321


isReading

isReading(): boolean

Checks to see if this resource is being read

Returns

boolean

true if the resource is currently being read

Example

resource.read().then(() => {
  // Logs "false"
  console.log(resource.isReading())
});
// Logs "true"
console.log(resource.isReading());

Inherited from

Resource.isReading

Defined in

packages/solid/src/resource/Resource.ts:184


isReloading

isReloading(): boolean

Checks to see if this resource is being read for a subsequent time

Returns

boolean

true if the resource is currently being read for a subsequent time

Example

await resource.read();
resource.read().then(() => {
  // Logs "false"
  console.log(resource.isCreating())
});
// Logs "true"
console.log(resource.isCreating());

Inherited from

Resource.isReloading

Defined in

packages/solid/src/resource/Resource.ts:239


isSubscribedToNotifications

isSubscribedToNotifications(): boolean

Is this resource currently listening to notifications from this document

Returns

boolean

true if the resource is subscribed to notifications, false if not

Example

await resource.subscribeToNotifications();
// Logs "true"
console.log(resource.isSubscribedToNotifications());

Inherited from

Resource.isSubscribedToNotifications

Defined in

packages/solid/src/resource/Resource.ts:336


isUnfetched

isUnfetched(): boolean

Check to see if this resource is currently unfetched

Returns

boolean

true if the resource is currently unfetched

Example

// Logs "true"
console.log(resource.isUnetched());
const result = await resource.read();
if (!result.isError) {
  // Logs "false"
  console.log(resource.isUnfetched());
}

Inherited from

Resource.isUnfetched

Defined in

packages/solid/src/resource/Resource.ts:283


isUpdating

isUpdating(): boolean

Checks to see if the resource is currently updating data

Returns

boolean

true if the current resource is updating

Example

leaf.update(datasetChanges).then(() => {
  // Logs "false"
  console.log(leaf.isUpdating())
});
// Logs "true"
console.log(leaf.isUpdating());

Defined in

packages/solid/src/resource/Leaf.ts:126


isUploading

isUploading(): boolean

Checks to see if the resource is currently uploading data

Returns

boolean

true if the current resource is uploading

Example

leaf.uploadAndOverwrite(new Blob("some text"), "text/txt").then(() => {
  // Logs "false"
  console.log(leaf.isUploading())
});
// Logs "true"
console.log(leaf.isUploading());

Defined in

packages/solid/src/resource/Leaf.ts:108


listenerCount

listenerCount\<E>(event): number

Type parameters

Name Type
E extends "update" | "notification"

Parameters

Name Type
event E

Returns

number

Inherited from

Resource.listenerCount

Defined in

node_modules/typed-emitter/index.d.ts:37


listeners

listeners\<E>(event): { notification: () => void ; update: () => void }[E][]

Type parameters

Name Type
E extends "update" | "notification"

Parameters

Name Type
event E

Returns

{ notification: () => void ; update: () => void }[E][]

Inherited from

Resource.listeners

Defined in

node_modules/typed-emitter/index.d.ts:36


off

off\<E>(event, listener): this

Type parameters

Name Type
E extends "update" | "notification"

Parameters

Name Type
event E
listener { notification: () => void ; update: () => void }[E]

Returns

this

Inherited from

Resource.off

Defined in

node_modules/typed-emitter/index.d.ts:28


on

on\<E>(event, listener): this

Type parameters

Name Type
E extends "update" | "notification"

Parameters

Name Type
event E
listener { notification: () => void ; update: () => void }[E]

Returns

this

Inherited from

Resource.on

Defined in

node_modules/typed-emitter/index.d.ts:23


onNotification

onNotification(message): Promise\<void>

Function that triggers whenever a notification is recieved.

Parameters

Name Type
message NotificationMessage

Returns

Promise\<void>

Inherited from

Resource.onNotification

Defined in

packages/solid/src/resource/Resource.ts:777


once

once\<E>(event, listener): this

Type parameters

Name Type
E extends "update" | "notification"

Parameters

Name Type
event E
listener { notification: () => void ; update: () => void }[E]

Returns

this

Inherited from

Resource.once

Defined in

node_modules/typed-emitter/index.d.ts:24


prependListener

prependListener\<E>(event, listener): this

Type parameters

Name Type
E extends "update" | "notification"

Parameters

Name Type
event E
listener { notification: () => void ; update: () => void }[E]

Returns

this

Inherited from

Resource.prependListener

Defined in

node_modules/typed-emitter/index.d.ts:25


prependOnceListener

prependOnceListener\<E>(event, listener): this

Type parameters

Name Type
E extends "update" | "notification"

Parameters

Name Type
event E
listener { notification: () => void ; update: () => void }[E]

Returns

this

Inherited from

Resource.prependOnceListener

Defined in

node_modules/typed-emitter/index.d.ts:26


rawListeners

rawListeners\<E>(event): { notification: () => void ; update: () => void }[E][]

Type parameters

Name Type
E extends "update" | "notification"

Parameters

Name Type
event E

Returns

{ notification: () => void ; update: () => void }[E][]

Inherited from

Resource.rawListeners

Defined in

node_modules/typed-emitter/index.d.ts:35


read

read(): Promise\<ResourceResult\<ReadLeafResult, Leaf>>

Reads the leaf by making a request

Returns

Promise\<ResourceResult\<ReadLeafResult, Leaf>>

A read result

Example

const result = await leaf.read();
if (result.isError) {
  // Do something
}

Overrides

Resource.read

Defined in

packages/solid/src/resource/Leaf.ts:240


readIfUnfetched

readIfUnfetched(): Promise\<ResourceResult\<ReadLeafResult, Leaf>>

Makes a request to read this leaf if it hasn't been fetched yet. If it has, return the cached informtation

Returns

Promise\<ResourceResult\<ReadLeafResult, Leaf>>

a ReadLeafResult

Example

const result = await leaf.read();
if (!result.isError) {
  // Will execute without making a request
  const result2 = await leaf.readIfUnfetched();
}

Overrides

Resource.readIfUnfetched

Defined in

packages/solid/src/resource/Leaf.ts:295


removeAllListeners

removeAllListeners\<E>(event?): this

Type parameters

Name Type
E extends "update" | "notification"

Parameters

Name Type
event? E

Returns

this

Inherited from

Resource.removeAllListeners

Defined in

node_modules/typed-emitter/index.d.ts:29


removeListener

removeListener\<E>(event, listener): this

Type parameters

Name Type
E extends "update" | "notification"

Parameters

Name Type
event E
listener { notification: () => void ; update: () => void }[E]

Returns

this

Inherited from

Resource.removeListener

Defined in

node_modules/typed-emitter/index.d.ts:30


setMaxListeners

setMaxListeners(maxListeners): this

Parameters

Name Type
maxListeners number

Returns

this

Inherited from

Resource.setMaxListeners

Defined in

node_modules/typed-emitter/index.d.ts:40


setWac

setWac(wacRule): Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | NotFoundHttpError | SetWacRuleSuccess>

Sets access rules for a specific resource

Parameters

Name Type Description
wacRule WacRule the access rules to set

Returns

Promise\<UnexpectedResourceError | NoncompliantPodError | ServerHttpError | UnexpectedHttpError | UnauthenticatedHttpError | UnauthorizedHttpError | NotFoundHttpError | SetWacRuleSuccess>

SetWacRuleResult

Example

const resource = ldoSolidDataset
  .getResource("https://example.com/container/resource.ttl");
const wacRulesResult = await resource.setWac({
  public: {
    read: true,
    write: false,
    append: false,
    control: false
  },
  authenticated: {
    read: true,
    write: false,
    append: true,
    control: false
  },
  agent: {
    "https://example.com/person1/profile/card#me": {
      read: true,
      write: true,
      append: true,
      control: true
    }
  }
});

Inherited from

Resource.setWac

Defined in

packages/solid/src/resource/Resource.ts:708


subscribeToNotifications

subscribeToNotifications(callbacks?): Promise\<string>

Activates Websocket subscriptions on this resource. Updates, deletions, and creations on this resource will be tracked and all changes will be relected in LDO's resources and graph.

Parameters

Name Type
callbacks? SubscriptionCallbacks

Returns

Promise\<string>

SubscriptionId: A string to use to unsubscribe

Example

const resource = solidLdoDataset
  .getResource("https://example.com/spiderman");
// A listener for if anything about spiderman in the global dataset is
// changed. Note that this will also listen for any local changes as well
// as changes to remote resources to which you have notification
// subscriptions enabled.
solidLdoDataset.addListener(
  [namedNode("https://example.com/spiderman#spiderman"), null, null, null],
  () => {
    // Triggers when the file changes on the Pod or locally
    console.log("Something changed about SpiderMan");
  },
);

// Subscribe
const subscriptionId = await testContainer.subscribeToNotifications({
  // These are optional callbacks. A subscription will automatically keep
  // the dataset in sync. Use these callbacks for additional functionality.
  onNotification: (message) => console.log(message),
  onNotificationError: (err) => console.log(err.message)
});
// ... From there you can wait for a file to be changed on the Pod.

#### Inherited from

[Resource](Resource.md).[subscribeToNotifications](Resource.md#subscribetonotifications)

#### Defined in

[packages/solid/src/resource/Resource.ts:765](https://github.com/o-development/ldo/blob/c70613a/packages/solid/src/resource/Resource.ts#L765)

___

### toReadResult

 **toReadResult**(): `ResourceResult`\<[`ReadLeafResult`](../types/ReadLeafResult.md), [`Leaf`](Leaf.md)\>

Converts the current state of this leaf to a readResult

#### Returns

`ResourceResult`\<[`ReadLeafResult`](../types/ReadLeafResult.md), [`Leaf`](Leaf.md)\>

a ReadLeafResult

#### Overrides

[Resource](Resource.md).[toReadResult](Resource.md#toreadresult)

#### Defined in

[packages/solid/src/resource/Leaf.ts:251](https://github.com/o-development/ldo/blob/c70613a/packages/solid/src/resource/Leaf.ts#L251)

___

### unsubscribeFromAllNotifications

 **unsubscribeFromAllNotifications**(): `Promise`\<`void`\>

Unsubscribes from all notifications on this resource

#### Returns

`Promise`\<`void`\>

UnsubscribeResult[]

**`Example`**

```typescript
const subscriptionResult = await testContainer.subscribeToNotifications();
await testContainer.unsubscribeFromAllNotifications();

Inherited from

Resource.unsubscribeFromAllNotifications

Defined in

packages/solid/src/resource/Resource.ts:831


unsubscribeFromNotifications

unsubscribeFromNotifications(subscriptionId): Promise\<void>

Unsubscribes from changes made to this resource on the Pod

Parameters

Name Type
subscriptionId string

Returns

Promise\<void>

UnsubscribeResult

Example

const subscriptionId = await testContainer.subscribeToNotifications();
await testContainer.unsubscribeFromNotifications(subscriptionId);

Inherited from

Resource.unsubscribeFromNotifications

Defined in

packages/solid/src/resource/Resource.ts:814


update

update(changes): Promise\<ResourceResult\<UpdateResult, Leaf>>

Updates a data resource with the changes provided

Parameters

Name Type Description
changes DatasetChanges\<Quad> Dataset changes that will be applied to the resoruce

Returns

Promise\<ResourceResult\<UpdateResult, Leaf>>

An UpdateResult

Example

import {
  updateDataResource,
  transactionChanges,
  changeData,
  createSolidLdoDataset,
} from "@ldo/solid";

//...

// Get a Linked Data Object
const profile = solidLdoDataset
  .usingType(ProfileShapeType)
  .fromSubject("https://example.com/profile#me");
cosnt resource = solidLdoDataset
  .getResource("https://example.com/profile");
// Create a transaction to change data
const cProfile = changeData(profile, resource);
cProfile.name = "John Doe";
// Get data in "DatasetChanges" form
const datasetChanges = transactionChanges(someLinkedDataObject);
// Use "update" to apply the changes
cosnt result = resource.update(datasetChanges);

Defined in

packages/solid/src/resource/Leaf.ts:548


updateWithCreateSuccess

updateWithCreateSuccess(_result): void

A helper method updates this leaf's internal state upon create success

Parameters

Name Type Description
_result ResourceSuccess the result of the create success

Returns

void

Overrides

Resource.updateWithCreateSuccess

Defined in

packages/solid/src/resource/Leaf.ts:395


updateWithDeleteSuccess

updateWithDeleteSuccess(result): void

A helper method updates this leaf's internal state upon delete success

Parameters

Name Type Description
result DeleteSuccess the result of the delete success

Returns

void

Overrides

Resource.updateWithDeleteSuccess

Defined in

packages/solid/src/resource/Leaf.ts:365


updateWithReadSuccess

updateWithReadSuccess(result): void

A helper method updates this leaf's internal state upon read success

Parameters

Name Type Description
result BinaryReadSuccess | DataReadSuccess | AbsentReadSuccess the result of the read success

Returns

void

Overrides

Resource.updateWithReadSuccess

Defined in

packages/solid/src/resource/Leaf.ts:217


uploadAndOverwrite

uploadAndOverwrite(blob, mimeType): Promise\<ResourceResult\<LeafCreateAndOverwriteResult, Leaf>>

Uploads a binary resource to this URI. If there is already a resource present at this URI, it will be overwritten

Parameters

Name Type Description
blob Blob the Blob of the binary
mimeType string the MimeType of the binary

Returns

Promise\<ResourceResult\<LeafCreateAndOverwriteResult, Leaf>>

A LeafCreateAndOverwriteResult

Example

const result = await leaf.uploadAndOverwrite(
  new Blob("some text."),
  "text/txt",
);
if (!result.isError) {
  // Do something
}

Defined in

packages/solid/src/resource/Leaf.ts:466


uploadIfAbsent

uploadIfAbsent(blob, mimeType): Promise\<ResourceResult\<LeafCreateIfAbsentResult, Leaf>>

Uploads a binary resource to this URI tf there not is already a resource present at this URI.

Parameters

Name Type Description
blob Blob the Blob of the binary
mimeType string the MimeType of the binary

Returns

Promise\<ResourceResult\<LeafCreateIfAbsentResult, Leaf>>

A LeafCreateIfAbsentResult

Example

const result = await leaf.uploadIfAbsent(
  new Blob("some text."),
  "text/txt",
);
if (!result.isError) {
  // Do something
}

Defined in

packages/solid/src/resource/Leaf.ts:498