Leveraging the Definitions API
caution
The Definitions
API is still very experimental, and subject to change.
When designing your networking objects, it may become cumbersome to keep references to all your remotes all over the place.
#
The standard wayYou may define a remote on the server, as such:
- roblox-ts
- luau
And then of course, a parallel client remote on the client.
- roblox-ts
- luau
While this works very well, you may want a single place to reference all your remote objects and handle all the types for you. As you can see above, maintaining types could get very hectic. This is where Definitions
come in.
#
Definitions, oh my!One of the new cool features of v2.0 is the Net.Definitions namespace. Now we can define our remotes in a single place, rather than having to maintain separate references:
- roblox-ts
- luau
And how do we use these in the client and server?
And how do we use these in the client and server?
Simple! note the lack of needing type information outside of the definitions file. If you want to use your definitions in multiple places, you don't have to worry about your types being out of sync!