UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.

25 lines (24 loc) 1.37 kB
export declare type SyncFieldOptions = { onPropertyChanged: Function; }; export declare type FieldChangedCallbackFn = (newValue: any, previousValue: any) => void | boolean | any; /** * **Decorate a field to be automatically networked synced** * *Primitive* values are all automatically synced (like string, boolean, number). * For *arrays or objects* make sure to re-assign them (e.g. `this.mySyncField = this.mySyncField`) to trigger an update * * @param onFieldChanged name of a callback function that will be called when the field is changed. * You can also pass in a function like so: syncField(myClass.prototype.myFunctionToBeCalled) * Note: if you return `false` from this function you'll prevent the field from being synced with other clients * (for example a networked color is sent as a number and may be converted to a color in the receiver again) * Parameters: (newValue, previousValue) */ export declare const syncField: (onFieldChanged?: string | FieldChangedCallbackFn | undefined | null) => (target: any, _propertyKey: string | { name: string; }) => void; export declare type SyncOptions = { key?: string; fieldName?: string; }; /** experimental - use syncField instead */ export declare const sync: (_options?: SyncOptions) => <T>(target: any, _propertyKey: string, descriptor: PropertyDescriptor) => void;