mirror of
https://github.com/littensy/charm.git
synced 2026-10-22 04:14:08 +00:00
chore: housekeeping
This commit is contained in:
parent
3134136e70
commit
c842926abe
6 changed files with 44 additions and 36 deletions
|
|
@ -9,19 +9,22 @@ return {
|
|||
Whether the history of state changes since the client's last update
|
||||
should be preserved. This is useful for values that change multiple
|
||||
times per frame, where each individual change is important. Defaults
|
||||
to `false`.
|
||||
to `false` for performance reasons.
|
||||
]]
|
||||
preserveHistory = false,
|
||||
--[[
|
||||
When `true`, Charm will apply validation and serialize unsafe arrays
|
||||
to address remote event argument limitations. Defaults to `true`.
|
||||
When `true`, Charm will modify sparse arrays to prevent data loss from
|
||||
remote event limitations. When an unsafe array is detected, numeric
|
||||
indices will be converted to string keys so that the array can be sent
|
||||
safely and then converted back to an array on the receiving end.
|
||||
|
||||
This option should be disabled if your network library uses a custom
|
||||
serialization method (i.e. Zap, ByteNet) to prevent interference.
|
||||
]]
|
||||
fixArrays = true,
|
||||
--[[
|
||||
When `true`, synced state containing unsafe sparse arrays or mixed
|
||||
tables will throw an error. Only checked in strict mode and if
|
||||
tables will emit a warning. Only checked in strict mode and if
|
||||
`fixArrays` is enabled. Defaults to `true`.
|
||||
]]
|
||||
validatePatches = true,
|
||||
|
|
|
|||
13
packages/charm-sync/src/index.d.ts
vendored
13
packages/charm-sync/src/index.d.ts
vendored
|
|
@ -78,14 +78,17 @@ export const config: {
|
|||
* Whether the history of state changes since the client's last update
|
||||
* should be preserved. This is useful for values that change multiple
|
||||
* times per frame, where each individual change is important. Defaults
|
||||
* to `false`.
|
||||
* to `false` for performance reasons.
|
||||
*
|
||||
* @server
|
||||
*/
|
||||
preserveHistory: boolean;
|
||||
/**
|
||||
* When `true`, Charm will apply validation and serialize unsafe arrays
|
||||
* to address remote event argument limitations. Defaults to `true`.
|
||||
* When `true`, Charm will modify sparse arrays to prevent data loss from
|
||||
* remote event limitations. When an unsafe array is detected, numeric
|
||||
* indices will be converted to string keys so that the array can be sent
|
||||
* safely and then converted back to an array on the receiving end.
|
||||
*
|
||||
* This option should be disabled if your network library uses a custom
|
||||
* serialization method (i.e. Zap, ByteNet) to prevent interference.
|
||||
*
|
||||
|
|
@ -94,7 +97,7 @@ export const config: {
|
|||
fixArrays: boolean;
|
||||
/**
|
||||
* When `true`, synced state containing unsafe sparse arrays or mixed
|
||||
* tables will throw an error. Only checked in strict mode and if
|
||||
* tables will emit a warning. Only checked in strict mode and if
|
||||
* `fixArrays` is enabled. Defaults to `true`.
|
||||
*
|
||||
* @server
|
||||
|
|
@ -242,7 +245,7 @@ export namespace patch {
|
|||
* @param statePatch The patches to apply.
|
||||
* @returns The new state with the patch applied.
|
||||
*/
|
||||
export function apply<State, FixArrays extends boolean = true>(
|
||||
export function applyImmutable<State, FixArrays extends boolean = true>(
|
||||
currentState: State,
|
||||
statePatch: SyncPatch<State, FixArrays>,
|
||||
): State;
|
||||
|
|
|
|||
|
|
@ -497,7 +497,7 @@ end)
|
|||
|
||||
test("recursive effects should run and cleanup in order", function()
|
||||
local a, setA = signal(0)
|
||||
local order = {}
|
||||
local order: { string } = {}
|
||||
|
||||
effect(function()
|
||||
local value = a()
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ end)
|
|||
|
||||
test("should handle recursive additions and removals", function()
|
||||
local items, setItems = signal({ 1 })
|
||||
local edits = {}
|
||||
local edits: { string } = {}
|
||||
|
||||
observe(items, function(item)
|
||||
if item < 5 then
|
||||
|
|
@ -114,7 +114,7 @@ end)
|
|||
|
||||
test("should handle self removal", function()
|
||||
local items, setItems = signal({ 1, 2, 3, 4 })
|
||||
local edits = {}
|
||||
local edits: { string } = {}
|
||||
|
||||
observe(items, function(item, index)
|
||||
setItems(function(state: { number })
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ test("should run in untracked", function()
|
|||
end)
|
||||
|
||||
test("should ensure correct execution order", function()
|
||||
local order = {}
|
||||
local order: { number } = {}
|
||||
local n1, setN1 = signal(0)
|
||||
local n2, setN2 = signal(0)
|
||||
local sum = computed(function()
|
||||
|
|
@ -72,7 +72,7 @@ test("should ensure correct execution order", function()
|
|||
end)
|
||||
|
||||
test("should skip redundant updates", function()
|
||||
local order = {}
|
||||
local order: { "even" | "odd" } = {}
|
||||
local a, setA = signal(0)
|
||||
|
||||
subscribe(function(): "even" | "odd"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue