Supported on
Sync Realtime Store
SyncRealtimeStore is a Sync Entity and realtime store
exposed as a scene component, with no behavior of its own. Use it when you want
somewhere to keep synced values without writing a script that constructs a Sync
Entity, or when another script needs a store it can reference in the Inspector.
Component Inputs
| Name | Type | Description |
|---|---|---|
| Network Id Type | Object Id or Custom | How the network id is generated. Defaults to Object Id. |
| Custom Network Id | string | Shown when Network Id Type is Custom. Defaults to enter_unique_id. |
| Ownership | Owned, Unowned, or Host Owned | Who may write to the store. Defaults to Unowned. |
Component API
| Name (signature) | Description |
|---|---|
syncEntity | The underlying Sync Entity. |
isStoreReady(): boolean | Whether the store exists and is ready. |
getStore(): GeneralDataStore | null | The underlying store. |
getStoreOwnerInfo(): ConnectedLensModule.UserInfo | null | Current owner, if any. |
canIModifyStore(): boolean | Whether the local client may write. Check before writing. |
doIOwnStore(): boolean | Whether the local client owns the store. |
isStoreOwned(): boolean | Whether anyone owns the store. |
isHostOwned(): boolean | Whether the store is host-owned. |
addStorageProperty<T>(storageProperty: StorageProperty<T>): StorageProperty<T> | Adds a storage property to the store, returning it. |
Events
These pass straight through from the underlying Sync Entity: onStoreCreated,
onStoreUpdated, onStoreOwnershipUpdated, onStoreDeleted,
onSetupFinished, onOwnerUpdated.
Usage
import { SyncRealtimeStore } from 'ConnectedFramework.lspkg/Components/SyncRealtimeStore';
import { StorageProperty } from 'ConnectedFramework.lspkg/Core/StorageProperty';
@component
export class RoundTimer extends BaseScriptComponent {
@input
store!: SyncRealtimeStore;
private secondsLeft!: StorageProperty<number>;
onAwake() {
this.secondsLeft = this.store.addStorageProperty(
StorageProperty.manualInt('secondsLeft', 60)
);
this.store.onSetupFinished.add(() => {
print(`Timer ready at ${this.secondsLeft.currentValue}`);
});
}
}
Related
- Sync Entity: use this directly when you want the entity in code.
- Storage Property
Was this page helpful?