Whether the document is connected to the backend and should be modified. If this becomes false, the user became offline or the backend server is down. Will usually recover on its own.
While this is false, no syncing is happening, and all changes made since this became false will be lost on reload; it's recommended to block the user from making changes until this becomes true again.
Acquire the transaction lock and receive a transaction builder to modify the document.
While a transaction builder exists, no other can be created - subsequent calls will have to await.
Once the transaction is complete, call .send() on the builder to release the lock and let
the next transaction begin.
Subscribe to changes in the document.
Query the current state of the document. Careful: Acquiring the transaction lock is an async process, and has to be awaited; during that wait time, the document can change. It's thus recommended to use TransactionBuilder.entities to query the document when building transactions, otherwise transaction errors can occur.
Start the synchronization process with the backend.
Before this method is called:
Which gives you time to setup all onCreate event listeners.
While the returned promise resolves, the local state is synced up with the remote state,
and all entities currently in the document trigger onCreate callbacks. After the method resolves,
the document is in sync, and can be modified.
Stop syncing to the backend, so the document can be thrown away.
Concretely, if modify and createTransaction are called after this is called, they will throw an error.
The promise will resolve once already pending modify and createTransaction calls have finished, and the modifications they create have been synced with the backend.
After this is called, only queryEntities can be used. No event will ever be triggered again.
This method must be called before the document can be thrown away. Not doing so will result in the syncing process continuing, and the document never being garbage collected. It will also prevent native runtimes from exiting the process.
Execute a transaction with automatic cleanup.
This is the most common way to modify the document. It handles transaction creation, execution, and cleanup automatically.
Function that receives a transaction builder and performs modifications
Promise resolving to the return value of the transaction function
// Create a tonematrix and place it on the desktop
const tonematrix = await nexus.modify((t) => {
const tm = t.create("tonematrix", {});
const placement = t.create("desktopPlacement", {
entity: tm.location,
x: 100,
y: 200
});
return tm;
});
// Update multiple fields in one transaction
await nexus.modify((t) => {
t.update(delay.fields.delayTime, 0.75);
t.update(delay.fields.feedback, 0.6);
t.update(delay.fields.mixFactor, 0.4);
});
An Audiotool project document that synchronizes in real-time with the backend.
This is the main interface for interacting with Audiotool projects. It provides methods for creating transactions, querying entities, and reacting to changes.
Example
See
createAudiotoolClient for creating client instances