mirror of
https://github.com/littensy/charm.git
synced 2026-10-20 17:51:37 +00:00
feat: add flag for inner effect tracking
This commit is contained in:
parent
87e7260c16
commit
027c5bf8f8
4 changed files with 7 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -8,5 +8,6 @@
|
||||||
node_modules
|
node_modules
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
*.rbxm
|
*.rbxm
|
||||||
|
*.tgz
|
||||||
.DS_Store
|
.DS_Store
|
||||||
roblox.d.luau
|
roblox.d.luau
|
||||||
|
|
|
||||||
|
|
@ -349,7 +349,7 @@ local function effect(fn: (dispose: () -> ()) -> ...(() -> ())?): () -> ()
|
||||||
cleanup = nil :: any,
|
cleanup = nil :: any,
|
||||||
}
|
}
|
||||||
self.cleanup = effectStop(self)
|
self.cleanup = effectStop(self)
|
||||||
if activeSub then
|
if activeSub and config.trackInnerEffects then
|
||||||
link(self, activeSub)
|
link(self, activeSub)
|
||||||
elseif activeScope then
|
elseif activeScope then
|
||||||
link(self, activeScope)
|
link(self, activeScope)
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,8 @@ return {
|
||||||
--- Enforces immutability of atoms by deep-freezing table values. Enabled
|
--- Enforces immutability of atoms by deep-freezing table values. Enabled
|
||||||
--- if the optimization level is below 2, which is true in studio.
|
--- if the optimization level is below 2, which is true in studio.
|
||||||
frozen = not isO2,
|
frozen = not isO2,
|
||||||
|
--- Whether inner effects should clean up after themselves when their
|
||||||
|
--- parent effect re-runs. This is usually desirable, but can be disabled
|
||||||
|
--- to revert to the old behavior. Defaults to `true`.
|
||||||
|
trackInnerEffects = true,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
packages/charm/src/index.d.ts
vendored
1
packages/charm/src/index.d.ts
vendored
|
|
@ -13,6 +13,7 @@ export type Equals<T> = (current: T, incoming: T) => boolean;
|
||||||
export const flags: {
|
export const flags: {
|
||||||
strict: boolean;
|
strict: boolean;
|
||||||
frozen: boolean;
|
frozen: boolean;
|
||||||
|
trackInnerEffects: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function atom<T>(value: T, equals?: Equals<T>): Atom<T>;
|
export function atom<T>(value: T, equals?: Equals<T>): Atom<T>;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue