docs: add fishing game example project

This commit is contained in:
littensy 2025-11-23 16:28:11 -08:00
parent 391125b3a2
commit aebe3d27ee
2 changed files with 7 additions and 8 deletions

View file

@ -981,7 +981,7 @@ Charm v0.11 introduces _a lot_ of breaking changes, so below are some tips that
## Examples
Check out this simple [example project →](https://github.com/littensy/charm-example)
- https://github.com/littensy/fishing-minigame: Fisch clone using Charm for server and client state
### React Counter

View file

@ -889,7 +889,7 @@ local function reactive<T>(initialValue: T & {}): (T, (update: (T) -> () | T?) -
end
function proxyApi.__newindex(self: ReactiveProxy, key: any, value: any)
if type(value) == "table" and getmetatable(value) == proxyApi then
if type(value) == "table" and type(value.__target) == "table" then
value = value.__target
end
if self.__target[key] ~= value then
@ -932,13 +932,12 @@ end
@see https://github.com/littensy/charm?tab=readme-ov-file#reactiveinitialvalue
]]
local function toRaw<T>(value: T): T
if type(value) == "table" and getmetatable(value) ~= nil then
local value: ReactiveProxy = value
local api = getmetatable(value)
if api then
api.track()
return value.__target :: any
if type(value) == "table" and type(value.__target) == "table" then
-- Iteration starts tracking the reactive proxy
for _ in value do
break
end
return value.__target
end
return value
end