a library to speed up the development of Fivem scripts and frameworks
fivem-ts - Documentation v0.7.5 • Docs
fivem-ts - Documentation v0.7.5 / Shared / ClientOnly
ClientOnly(
target
,propertyKey
,descriptor
):void
A decorator that ensures a method is only executed on the client side.
The @ClientOnly
decorator modifies the behavior of the decorated method to prevent its execution
on the server side. If the method is called on the server side, a warning is logged and the method is replaced
with an empty function to prevent any unintended behavior.
Note: This decorator intended to be used in environments where both server and client code can be executed, such as in frameworks that support both server-side and client-side execution
• target: unknown
The prototype of the class.
• propertyKey: string
The name of the method being decorated.
• descriptor: PropertyDescriptor
The property descriptor for the method.
void
class Example {
@ClientOnly
public clientMethod() {
console.log('This method should only run on the client side.');
}
}
const example = new Example();
example.clientMethod(); // Executes only if running on the client side.