refactor(sync): create AtomMap type

This commit is contained in:
Richard 2025-01-25 16:07:28 -08:00
parent 884e6c0e8c
commit 63388761f8
3 changed files with 11 additions and 2 deletions

View file

@ -1,13 +1,14 @@
local Charm = require(script.Parent.Parent.Charm) local Charm = require(script.Parent.Parent.Charm)
local patch = require(script.Parent.patch) local patch = require(script.Parent.patch)
local types = require(script.Parent.types) local types = require(script.Parent.types)
type AtomMap = types.AtomMap
type SyncPayload = types.SyncPayload type SyncPayload = types.SyncPayload
type ClientOptions = { type ClientOptions = {
--[=[ --[=[
The atoms to synchronize with the server. The atoms to synchronize with the server.
]=] ]=]
atoms: { [string | number]: Charm.Atom<any> }, atoms: AtomMap,
--[=[ --[=[
Whether to ignore patches sent before the client has been hydrated. Whether to ignore patches sent before the client has been hydrated.
Default is `true`. Default is `true`.

View file

@ -4,13 +4,14 @@ local Charm = require(script.Parent.Parent.Charm)
local interval = require(script.Parent.interval) local interval = require(script.Parent.interval)
local patch = require(script.Parent.patch) local patch = require(script.Parent.patch)
local types = require(script.Parent.types) local types = require(script.Parent.types)
type AtomMap = types.AtomMap
type SyncPayload = types.SyncPayload type SyncPayload = types.SyncPayload
type ServerOptions = { type ServerOptions = {
--[=[ --[=[
The atoms to synchronize with the client. The atoms to synchronize with the client.
]=] ]=]
atoms: { [string | number]: Charm.Atom<any> }, atoms: AtomMap,
--[=[ --[=[
The interval at which to send patches to the client, in seconds. The interval at which to send patches to the client, in seconds.
Defaults to `0` (patches are sent up to once per frame). Set to a Defaults to `0` (patches are sent up to once per frame). Set to a

View file

@ -1,3 +1,6 @@
local Charm = require(script.Parent.Parent.Charm)
type Atom<T> = Charm.Atom<T>
--[=[ --[=[
A payload that can be sent from the server to the client to synchronize A payload that can be sent from the server to the client to synchronize
state between the two. state between the two.
@ -10,4 +13,8 @@ export type SyncPayload = {
data: { [string | number]: any }, data: { [string | number]: any },
} }
export type AtomMap = {
[string | number]: Atom<any>,
}
return nil return nil