From aebe3d27ee3654444fd866801b807ce0f79cbb64 Mon Sep 17 00:00:00 2001 From: littensy <56808540+littensy@users.noreply.github.com> Date: Sun, 23 Nov 2025 16:28:11 -0800 Subject: [PATCH] docs: add fishing game example project --- README.md | 2 +- packages/charm/src/init.luau | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d2301ef..b5a7a2f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/packages/charm/src/init.luau b/packages/charm/src/init.luau index e31702f..ca45ce9 100644 --- a/packages/charm/src/init.luau +++ b/packages/charm/src/init.luau @@ -889,7 +889,7 @@ local function reactive(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(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