ClientNetWire
Client-side NetWire implementation using Sleitnick's Comm under the hood. Provides a clean interface for consuming server-exposed networking APIs.
Structure:
ClientNetWireClass: Contains static methods (utilities, promises, etc.)ClientNetWire: Contains instance methods and constructor
This separation ensures better linting support and prevents static methods from appearing in instance method suggestions.
Key Features:
- Promise-based readiness: Wait for server APIs to become available
- Automatic proxy creation: Seamless access to server methods and events
- Type safety: Full typing support with proper metatable integration
- Middleware support: Promise conversion and other transformations
CAUTION
Wire indices may not always be ready for use immediately after creating a ClientNetWire. This can be the case if the ServerWire is created dynamically. To wait for a ClientNetWire to be ready for use, use NetWire.promiseWire. And then to wait for a particular index to be ready, use NetWire.promiseIndex.
local NetWire = require(game:GetService("ReplicatedStorage").NetWire)
local myNetWire = NetWire.Client("MyNetWire")
myNetWire:ServerSideFunction(someArg)
myNetWire.ServerSideEvent:Connect(function(someArg)
print(someArg)
end)
myNetWire.ServerSideEvent:Fire(someArg)
Types
ClientMiddleware
type ClientMiddleware = (args: {any}) → (shouldContinue: boolean,...any)Middleware function for client-side operations. Returns whether to continue processing and any modified arguments.
Functions
new
Creates a new ClientNetWire. If a ClientNetWire with the same nameSpace already exists, it will be returned instead.
onReady
Returns a promise that resolves when the ClientNetWire is ready for use.
isReady
Can be used to check if a clientNetWire is ready for use.
Accepts either a ClientNetWire instance or a string name of the wire.
Returns true if the ClientNetWire is ready, false otherwise.
indexReady
ClientNetWire.indexReady(idx: string--
The index to wait for existence of
) → Promise<...any>Returns a promise that resolves when the ClientNetWire is ready for use and the index exists. The resolved value is the value of the index.