mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 03:36:11 +00:00
feat: add peek and roblox-ts types
This commit is contained in:
parent
d2979ebd4c
commit
708bc55de7
37 changed files with 363 additions and 1234 deletions
|
|
@ -1,12 +1,7 @@
|
|||
local suite = require("../../../../test/suite")
|
||||
|
||||
suite.describe("vide-charm", function()
|
||||
if not game then
|
||||
return suite.skip()
|
||||
end
|
||||
suite.describe("useAtom", function()
|
||||
require("./useAtom.spec")
|
||||
end)
|
||||
suite.describe("useAtom", function()
|
||||
require("./useAtom.spec")
|
||||
end)
|
||||
|
||||
return {}
|
||||
|
|
|
|||
9
packages/vide-charm/src/index.d.ts
vendored
9
packages/vide-charm/src/index.d.ts
vendored
|
|
@ -1 +1,8 @@
|
|||
export {};
|
||||
/**
|
||||
* Subscribes to the state of an atom or selector. Returns a source that
|
||||
* updates when the state changes.
|
||||
*
|
||||
* @param callback The atom or selector to subscribe to.
|
||||
* @returns The reactive source.
|
||||
*/
|
||||
export function useAtom<T>(callback: () => T, dependencies?: any[]): () => T;
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ local cleanup = Vide.cleanup
|
|||
--- Subscribes to the state of an atom or selector. Returns a source that
|
||||
--- updates when the state changes.
|
||||
---
|
||||
--- @param selector The atom or selector to subscribe to.
|
||||
--- @param callback The atom or selector to subscribe to.
|
||||
--- @return The reactive source.
|
||||
local function useAtom<State>(selector: () -> State): () -> State
|
||||
local state = source(selector())
|
||||
cleanup(subscribe(selector, state))
|
||||
local function useAtom<State>(callback: () -> State): () -> State
|
||||
local state = source(callback())
|
||||
cleanup(subscribe(callback, state))
|
||||
return state
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue