Skip to content

Commit 09edb9c

Browse files
committed
Remove license, normalize API to be camelCase
1 parent aeeb7af commit 09edb9c

File tree

7 files changed

+63
-266
lines changed

7 files changed

+63
-266
lines changed

lib/LICENSE.lua

Lines changed: 0 additions & 203 deletions
This file was deleted.

lib/Signal.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ function Signal.new()
4646
return self
4747
end
4848

49-
function Signal:Connect(callback)
49+
function Signal:connect(callback)
5050
self._listeners = immutableAppend(self._listeners, callback)
5151

5252
local function disconnect()
5353
self._listeners = immutableRemoveValue(self._listeners, callback)
5454
end
5555

5656
return {
57-
Disconnect = disconnect
57+
disconnect = disconnect
5858
}
5959
end
6060

61-
function Signal:Fire(...)
61+
function Signal:fire(...)
6262
for _, listener in ipairs(self._listeners) do
6363
listener(...)
6464
end

lib/Signal.spec.lua

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ return function()
2020

2121
local signal = Signal.new()
2222

23-
local connection = signal:Connect(callback)
24-
signal:Fire(value1, value2)
23+
local connection = signal:connect(callback)
24+
signal:fire(value1, value2)
2525

2626
expect(callCount).to.equal(1)
2727

28-
connection:Disconnect()
29-
signal:Fire(value1, value2)
28+
connection:disconnect()
29+
signal:fire(value1, value2)
3030

3131
expect(callCount).to.equal(1)
3232
end)
@@ -38,10 +38,10 @@ return function()
3838

3939
local signal = Signal.new()
4040

41-
local connection = signal:Connect(callback)
42-
connection:Disconnect()
41+
local connection = signal:connect(callback)
42+
connection:disconnect()
4343

44-
signal:Fire()
44+
signal:fire()
4545
end)
4646

4747
it("should fire handlers in order", function()
@@ -61,9 +61,9 @@ return function()
6161
y = y + 1
6262
end
6363

64-
signal:Connect(callback1)
65-
signal:Connect(callback2)
66-
signal:Fire()
64+
signal:connect(callback1)
65+
signal:connect(callback2)
66+
signal:fire()
6767

6868
expect(x).to.equal(1)
6969
expect(y).to.equal(1)
@@ -75,16 +75,16 @@ return function()
7575
local countB = 0
7676

7777
local connectionA
78-
connectionA = signal:Connect(function()
79-
connectionA:Disconnect()
78+
connectionA = signal:connect(function()
79+
connectionA:disconnect()
8080
countA = countA + 1
8181
end)
8282

83-
signal:Connect(function()
83+
signal:connect(function()
8484
countB = countB + 1
8585
end)
8686

87-
signal:Fire()
87+
signal:fire()
8888

8989
expect(countA).to.equal(1)
9090
expect(countB).to.equal(1)

lib/Store.lua

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,20 @@ function Store.new(reducer, initialState)
2727
assert(type(reducer) == "function", "Bad argument #1 to Store.new, expected function.")
2828

2929
local self = {
30-
Reducer = reducer,
30+
_reducer = reducer,
31+
_state = reducer(initialState, {}),
3132
}
3233

33-
self._state = self.Reducer(initialState, {})
34-
3534
self._lastState = self._state
3635
self._mutatedSinceFlush = false
3736
self._connections = {}
3837

39-
self.Changed = Signal.new()
38+
self.changed = Signal.new()
4039

4140
setmetatable(self, Store)
4241

4342
local connection = self._flushEvent:Connect(function()
44-
self:Flush()
43+
self:flush()
4544
end)
4645
table.insert(self._connections, connection)
4746

@@ -51,7 +50,7 @@ end
5150
--[[
5251
Get the current state of the Store. Do not mutate this!
5352
]]
54-
function Store:GetState()
53+
function Store:getState()
5554
return self._state
5655
end
5756

@@ -64,21 +63,21 @@ end
6463
6564
Pass a function to dispatch a thunk.
6665
]]
67-
function Store:Dispatch(action)
66+
function Store:dispatch(action)
6867
if type(action) == "function" then
6968
local result = action(self)
7069

7170
return result
7271
else
73-
self._state = self.Reducer(self._state, action)
72+
self._state = self._reducer(self._state, action)
7473
self._mutatedSinceFlush = true
7574
end
7675
end
7776

7877
--[[
7978
Marks the store as deleted, disconnecting any outstanding connections.
8079
]]
81-
function Store:Destruct()
80+
function Store:destruct()
8281
for _, connection in ipairs(self._connections) do
8382
connection:Disconnect()
8483
end
@@ -89,7 +88,7 @@ end
8988
--[[
9089
Flush all pending actions since the last change event was dispatched.
9190
]]
92-
function Store:Flush()
91+
function Store:flush()
9392
if not self._mutatedSinceFlush then
9493
return
9594
end
@@ -104,7 +103,7 @@ function Store:Flush()
104103
-- If a Changed listener yields, *very* surprising bugs can ensue.
105104
-- Because of that, Changed listeners cannot yield.
106105
NoYield(function()
107-
self.Changed:Fire(state, self._lastState)
106+
self.changed:fire(state, self._lastState)
108107
end)
109108

110109
self._lastState = state

0 commit comments

Comments
 (0)