Skip to main content

@syncedstore/core

References

default

Renames and re-exports syncedStore

Functions

areSame

areSame(objectA, objectB): boolean

Check whether two objects represent the same value. A strict equality (===) check doesn't always work, because SyncedStore can wrap the object with a Proxy depending on where you retrieved it.

Parameters

NameTypeDescription
objectAanyObject to compare with objectB
objectBanyObject to compare with objectA

Returns

boolean

true if they represent the same object, false otherwise

Defined in

packages/core/src/index.ts:102


boxed

boxed<T>(value): Box<T>

Type parameters

NameType
Textends JSONValue

Parameters

NameType
valueT

Returns

Box<T>

Defined in

packages/core/src/boxed.ts:10


enableMobxBindings

enableMobxBindings(mobx): void

Enable MobX integration

Parameters

NameTypeDescription
mobxanyAn instance of mobx, e.g. import * as mobx from "mobx";

Returns

void

Defined in

packages/yjs-reactive-bindings/src/observableProvider.ts:46


enableVueBindings

enableVueBindings(vue): void

Enable Vue3 integration

Parameters

NameTypeDescription
vueanyAn instance of Vue or Vue reactivity, e.g. import * as Vue from "vue";

Returns

void

Defined in

packages/yjs-reactive-bindings/src/observableProvider.ts:56


filterArray

filterArray<T>(arr, filter): void

Filter a SyncedStore array

Type parameters

Name
T

Parameters

NameTypeDescription
arrT[]array to filter
filter(obj: T) => booleanpredicate to filter the array arr by

Returns

void

Defined in

packages/core/src/util.ts:6


getYjsDoc

getYjsDoc<T>(store): Y.Doc

Access the internal Yjs Doc.

Type parameters

Name
T

Parameters

NameTypeDescription
storeTa store returned by

Returns

Y.Doc

the Yjs doc (Y.Doc) underneath.

Defined in

packages/core/src/index.ts:67


getYjsValue

getYjsValue(object): Y.Doc | Y.AbstractType<any> | undefined

Access the internal Yjs value that backs the syncing of the passed in object.

Parameters

NameTypeDescription
objectanya value retrieved from the store

Returns

Y.Doc | Y.AbstractType<any> | undefined

the Yjs value underneath. This can be a Y.Doc, Y.Array, Y.Map or other Y-type based on the value passed in

Defined in

packages/core/src/index.ts:81


observeDeep

observeDeep(object, handler): () => void

Register a listener for when any changes to object or its nested objects occur.

Parameters

NameTypeDescription
objectanythe synced object (store, object, map, or Yjs value to observe)
handler() => voidthe callback to be raised.

Returns

fn

a function to dispose (unregister) the handler

▸ (): void

Register a listener for when any changes to object or its nested objects occur.

Returns

void

a function to dispose (unregister) the handler

Defined in

packages/core/src/index.ts:42


syncedStore

syncedStore<T>(shape, doc?): MappedTypeDescription<T>

Create a SyncedStore store

Type parameters

NameType
Textends DocTypeDescription

Parameters

NameTypeDescription
shapeTan object that describes the root types of the store. e.g.: const shape = { exampleArrayData: [], exampleObjectData: {}, exampleXMLData: "xml", exampleTextData: "text", };
docDoc(optional) a Y.Doc to use as the backing system

Returns

MappedTypeDescription<T>

a SyncedStore store

Defined in

packages/core/src/index.ts:130