mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 03:36:11 +00:00
refactor: rename Source to Molecule
This commit is contained in:
parent
f2ec300204
commit
0046af5598
11 changed files with 60 additions and 50 deletions
|
|
@ -1,14 +1,14 @@
|
|||
local capture = require(script.Parent.capture)
|
||||
local store = require(script.Parent.store)
|
||||
local types = require(script.Parent.types)
|
||||
type Source<T> = types.Source<T>
|
||||
type Molecule<T> = types.Molecule<T>
|
||||
|
||||
local function subscribe<T>(source: Source<T>, callback: (state: T, prev: T) -> ()): () -> ()
|
||||
local atoms, state = capture(source)
|
||||
local function subscribe<T>(molecule: Molecule<T>, callback: (state: T, prev: T) -> ()): () -> ()
|
||||
local atoms, state = capture(molecule)
|
||||
|
||||
local function listener()
|
||||
local prevState = state
|
||||
state = source()
|
||||
state = molecule()
|
||||
callback(state, prevState)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue