Package io.keikai.doc.collab.utils
Class Doc
java.lang.Object
io.keikai.doc.collab.lib0.ObservableV2
io.keikai.doc.collab.utils.Doc
A Yjs instance handles the state of shared data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Emit `destroy` event and unregister all event handlers.<T extends AbstractType>
Tget(String name, Class<? extends AbstractType> typeClz) Define a shared data type.getArray()intgetGuid()getItem()getMap()getMeta()getShare()getStore()getText()getXmlElement(String name) getXmlFragment(String name) booleanbooleanisGc()booleanisLoaded()booleanbooleanisSynced()voidload()Notify the parent document that you request to load data into this subdocument (if it is a subdocument).voidvoidvoidvoidvoidvoidvoidvoidvoidvoidonSync(BiConsumer<Boolean, Doc> f) voidvoidvoidvoidsetClientID(int clientID) voidsetCollectionID(String collectionID) voidsetGc(boolean gc) voidvoidvoidsetTransaction(Transaction transaction) voidsetTransactionCleanups(List<Transaction> transactionCleanups) toJSON()Deprecated.Do not use this method and rather call toJSON directly on the shared types.voidChanges that happen inside a transaction are bundled.voidChanges that happen inside a transaction are bundled.voidChanges that happen inside a transaction are bundled.voidtransact(Consumer<Transaction> f, Object origin) Changes that happen inside a transaction are bundled.<T> Ttransact(Function<Transaction, T> f) Changes that happen inside a transaction are bundled.<T> Ttransact(Function<Transaction, T> f, Object origin) Changes that happen inside a transaction are bundled.
-
Constructor Details
-
Doc
public Doc()A Yjs instance handles the state of shared data. -
Doc
A Yjs instance handles the state of shared data.- Parameters:
opts- configuration
-
-
Method Details
-
isGc
public boolean isGc() -
setGc
public void setGc(boolean gc) -
getGcFilter
-
getClientID
public int getClientID() -
setClientID
public void setClientID(int clientID) -
getGuid
-
setGuid
-
getCollectionID
-
setCollectionID
-
getStore
-
getTransaction
-
setTransaction
-
getTransactionCleanups
-
setTransactionCleanups
-
getItem
-
setItem
-
isShouldLoad
public boolean isShouldLoad() -
isAutoLoad
public boolean isAutoLoad() -
getMeta
-
isLoaded
public boolean isLoaded() -
isSynced
public boolean isSynced() -
getWhenLoaded
-
getWhenSynced
-
onLoad
-
onDestroy
-
onSync
-
onUpdate
-
onUpdate
-
onUpdateV2
-
onBeforeAllTransactions
-
onBeforeTransaction
-
onBeforeObserverCalls
-
onAfterTransaction
-
onAfterTransactionCleanupCalls
-
onAfterAllTransactions
-
onSubdocs
-
load
public void load()Notify the parent document that you request to load data into this subdocument (if it is a subdocument).`load()` might be used in the future to request any provider to load the most current data.
It is safe to call `load()` multiple times.
-
getSubdocs
-
getSubdocGuids
-
transact
Changes that happen inside a transaction are bundled. This means that the observer fires _after_ the transaction is finished and that all changes that happened inside the transaction are sent as one message to the other peers.- Parameters:
f- The Runnable function that should be executed as a transaction
-
transact
Changes that happen inside a transaction are bundled. This means that the observer fires _after_ the transaction is finished and that all changes that happened inside the transaction are sent as one message to the other peers.- Parameters:
f- The Consumer function that should be executed as a transaction
-
transact
Changes that happen inside a transaction are bundled. This means that the observer fires _after_ the transaction is finished and that all changes that happened inside the transaction are sent as one message to the other peers.- Parameters:
f- The function that should be executed as a transaction- Returns:
- T
-
transact
Changes that happen inside a transaction are bundled. This means that the observer fires _after_ the transaction is finished and that all changes that happened inside the transaction are sent as one message to the other peers.- Parameters:
f- The Runnable function that should be executed as a transactionorigin- Origin of who started the transaction. Will be stored on transaction.origin
-
transact
Changes that happen inside a transaction are bundled. This means that the observer fires _after_ the transaction is finished and that all changes that happened inside the transaction are sent as one message to the other peers.- Parameters:
f- The Consumer function that should be executed as a transactionorigin- Origin of who started the transaction. Will be stored on transaction.origin
-
transact
Changes that happen inside a transaction are bundled. This means that the observer fires _after_ the transaction is finished and that all changes that happened inside the transaction are sent as one message to the other peers.- Parameters:
f- The function that should be executed as a transactionorigin- Origin of who started the transaction. Will be stored on transaction.origin- Returns:
- T
-
get
Define a shared data type.Multiple calls of `ydoc.get(name, typeClz)` yield the same result and do not overwrite each other. I.e. `ydoc.get(name, Y.Array) === ydoc.get(name, Y.Array)`
After this method is called, the type is also available on `ydoc.share.get(name)`.
*Best Practices:* Define all types right after the Y.Doc instance is created and store them in a separate object. Also use the typed methods `getText(name)`, `getArray(name)`, ..
- Parameters:
name-typeClz- The class of the type definition. E.g. YText, YArray, YMap, ...- Returns:
- The created type which class is typeClz
-
getArray
-
getArray
-
getText
-
getText
-
getMap
-
getMap
-
getXmlElement
-
getXmlElement
-
getXmlFragment
-
getXmlFragment
-
toJSON
Deprecated.Do not use this method and rather call toJSON directly on the shared types.Converts the entire document into a js object, recursively traversing each yjs type Doesn't log types that have not been defined (using ydoc.getType(..)).- Returns:
- Map
-
destroy
public void destroy()Emit `destroy` event and unregister all event handlers.- Overrides:
destroyin classObservableV2
-