mirror of
https://github.com/littensy/charm.git
synced 2026-10-22 04:14:08 +00:00
build: create project files for release
This commit is contained in:
parent
aff5f768bf
commit
b9d32ba4f2
13 changed files with 87 additions and 72 deletions
|
|
@ -1,25 +1 @@
|
|||
local Charm = require(script.Parent.charm)
|
||||
local Vide = if script.Parent:FindFirstChild("Vide")
|
||||
then require(script.Parent.Vide)
|
||||
else require((script.Parent :: any).vide.src) :: never
|
||||
|
||||
--[=[
|
||||
Subscribes to the state of an atom and returns a Vide source.
|
||||
|
||||
@param callback The atom or selector to subscribe to.
|
||||
@return The reactive source.
|
||||
]=]
|
||||
local function useAtom<State>(callback: () -> State): () -> State
|
||||
local state = Vide.source(callback())
|
||||
local unsubscribe = Charm.subscribe(callback, function(value)
|
||||
task.spawn(state :: (State) -> State, value)
|
||||
end)
|
||||
|
||||
Vide.cleanup(unsubscribe)
|
||||
|
||||
return state
|
||||
end
|
||||
|
||||
return {
|
||||
useAtom = useAtom,
|
||||
}
|
||||
return require(script.src)
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
"description": "Vide bindings for Charm",
|
||||
"repository": "littensy/charm",
|
||||
"license": "MIT",
|
||||
"main": "src/init.luau",
|
||||
"types": "src/index.d.ts",
|
||||
"main": "init.luau",
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"prepare": "cp ../../LICENSE.md . && cp ../../README.md .",
|
||||
"publish:wally": "wally publish"
|
||||
|
|
|
|||
25
packages/vide/src/init.luau
Normal file
25
packages/vide/src/init.luau
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
local Charm = require(script.Parent.Parent.charm)
|
||||
local Vide = if script.Parent.Parent:FindFirstChild("Vide")
|
||||
then require(script.Parent.Parent.Vide)
|
||||
else require((script.Parent.Parent :: any).vide.src) :: never
|
||||
|
||||
--[=[
|
||||
Subscribes to the state of an atom and returns a Vide source.
|
||||
|
||||
@param callback The atom or selector to subscribe to.
|
||||
@return The reactive source.
|
||||
]=]
|
||||
local function useAtom<State>(callback: () -> State): () -> State
|
||||
local state = Vide.source(callback())
|
||||
local unsubscribe = Charm.subscribe(callback, function(value)
|
||||
task.spawn(state :: (State) -> State, value)
|
||||
end)
|
||||
|
||||
Vide.cleanup(unsubscribe)
|
||||
|
||||
return state
|
||||
end
|
||||
|
||||
return {
|
||||
useAtom = useAtom,
|
||||
}
|
||||
|
|
@ -3,7 +3,8 @@ name = "littensy/vide-charm"
|
|||
version = "0.2.0"
|
||||
registry = "https://github.com/UpliftGames/wally-index"
|
||||
realm = "shared"
|
||||
exclude = ["package.json"]
|
||||
exclude = ["package.json", "node_modules"]
|
||||
include = ["LICENSE.md"]
|
||||
|
||||
[dependencies]
|
||||
charm = "littensy/charm@^0.9"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue