mirror of
https://github.com/littensy/charm.git
synced 2026-10-20 17:51:37 +00:00
docs: simplify examples
This commit is contained in:
parent
0f2f2d642c
commit
682b3dfcff
1 changed files with 12 additions and 6 deletions
18
README.md
18
README.md
|
|
@ -801,13 +801,15 @@ Check out this simple [example project →](https://github.com/littensy/charm-ex
|
|||
### React Counter
|
||||
|
||||
```luau
|
||||
local counterStore = require("./stores/counterStore")
|
||||
local getCounter, setCounter = signal(0)
|
||||
|
||||
local function Counter()
|
||||
local count = useSignalState(counterStore.getCounter)
|
||||
local count = useSignalState(getCounter)
|
||||
|
||||
return React.createElement("TextButton", {
|
||||
[React.Event.Activated] = counterStore.incrementCounter,
|
||||
[React.Event.Activated] = function()
|
||||
setCounter(count + 1)
|
||||
end,
|
||||
Text = `Count: {count}`,
|
||||
Size = UDim2.fromOffset(100, 50),
|
||||
})
|
||||
|
|
@ -817,13 +819,17 @@ end
|
|||
### Vide Counter
|
||||
|
||||
```luau
|
||||
local counterStore = require("./stores/counterStore")
|
||||
local getCounter, setCounter = signal(0)
|
||||
|
||||
local function Counter()
|
||||
local count = useSignalState(counterStore.getCounter)
|
||||
local count = useSignalState(getCounter)
|
||||
|
||||
return create "TextButton" {
|
||||
Activated = counterStore.incrementCounter,
|
||||
Activated = function()
|
||||
setCounter(function(count)
|
||||
return count + 1
|
||||
end)
|
||||
end,
|
||||
Text = function()
|
||||
return `Count: {count()}`
|
||||
end,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue