API Reference
interfaces
Linksyncadapter

@coasys/ad4m / Exports / LinkSyncAdapter

Interface: LinkSyncAdapter

Interface for "Link Languages" that facilitate the synchronization between agents' local Perspectives inside a Neighbourhood. The assumption is that every version of the shared Perspective is labeled with a unique revision string. Changes are committed and retrieved through diffs. Think of a LinkSyncAdapter as a git branch to which agents commit their changes to and pull diffs from their current revision to the latest one.

Table of contents

Methods

Methods

addCallback

addCallback(callback): any

Get push notification when a diff got published

Parameters

NameType
callbackPerspectiveDiffObserver

Returns

any

Defined in

language/Language.ts:186 (opens in a new tab)


addSyncStateChangeCallback

addSyncStateChangeCallback(callback): any

Add a sync state callback method

Parameters

NameType
callbackSyncStateChangeObserver

Returns

any

Defined in

language/Language.ts:189 (opens in a new tab)


commit

commit(diff): Promise<string>

Publish changes

Parameters

NameType
diffPerspectiveDiff

Returns

Promise<string>

Defined in

language/Language.ts:183 (opens in a new tab)


currentRevision

currentRevision(): Promise<string>

What revision are we on now -> what changes are included in output of render()

Returns

Promise<string>

Defined in

language/Language.ts:169 (opens in a new tab)


others

others(): Promise<string[]>

Returns

Promise<string[]>

Defined in

language/Language.ts:166 (opens in a new tab)


public

public(): boolean

Returns

boolean

Defined in

language/Language.ts:165 (opens in a new tab)


render

render(): Promise<Perspective>

Returns the full, rendered Perspective at currentRevision

Returns

Promise<Perspective>

Defined in

language/Language.ts:180 (opens in a new tab)


setLocalAgents

Optional setLocalAgents(agents): void

Set the local agents (DIDs) that own this perspective/neighbourhood. This is used to determine which agents should be registered in the DHT. Optional - if not implemented, all local agents may be registered.

This is a temporary hack to support multiple users on one node joining the same neighbourhood. Once we migrate the LanguageController to Rust and run Languages per user, each user will get their own language instance and we won't need to explicitly set local agents. This will provide better isolation and avoid the need to share language state between users.

Parameters

NameType
agentsstring[]

Returns

void

Defined in

language/Language.ts:201 (opens in a new tab)


sync

sync(): Promise<PerspectiveDiff>

Check for and get new changes, notify others of local changes. This function will be called every few seconds by the ad4m-executor.

Returns

Promise<PerspectiveDiff>

Defined in

language/Language.ts:177 (opens in a new tab)


writable

writable(): boolean

Returns

boolean

Defined in

language/Language.ts:164 (opens in a new tab)