Skip to content

Commit

Permalink
Merge pull request #407 from Quenty/users/quenty/misc
Browse files Browse the repository at this point in the history
Users/quenty/misc
  • Loading branch information
Quenty authored Sep 4, 2023
2 parents 3b7e47e + 46d4d39 commit c9cf806
Show file tree
Hide file tree
Showing 45 changed files with 1,084 additions and 410 deletions.
1 change: 1 addition & 0 deletions src/animations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@quenty/humanoidanimatorutils": "file:../humanoidanimatorutils",
"@quenty/loader": "file:../loader",
"@quenty/maid": "file:../maid",
"@quenty/promise": "file:../promise",
"@quenty/promisemaid": "file:../promisemaid",
"@quenty/rbxasset": "file:../rbxasset",
"@quenty/rx": "file:../rx",
Expand Down
4 changes: 3 additions & 1 deletion src/brio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
"dependencies": {
"@quenty/loader": "file:../loader",
"@quenty/maid": "file:../maid",
"@quenty/rx": "file:../rx"
"@quenty/rx": "file:../rx",
"@quenty/signal": "file:../signal",
"@quenty/steputils": "file:../steputils"
},
"publishConfig": {
"access": "public"
Expand Down
11 changes: 8 additions & 3 deletions src/brio/src/Shared/Brio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
local require = require(script.Parent.loader).load(script)

local Maid = require("Maid")
local GoodSignal = require("GoodSignal")

local Brio = {}
Brio.ClassName = "Brio"
Expand Down Expand Up @@ -136,11 +137,11 @@ function Brio:GetDiedSignal()
end

if self._diedEvent then
return self._diedEvent.Event
return self._diedEvent
end

self._diedEvent = Instance.new("BindableEvent")
return self._diedEvent.Event
self._diedEvent = GoodSignal.new()
return self._diedEvent
end

--[=[
Expand Down Expand Up @@ -205,6 +206,10 @@ function Brio:ToMaid()
return maid
end

function Brio:ToMaidAndValue()
return self:ToMaid(), self:GetValue()
end

--[=[
If the brio is not dead, will return the values unpacked from the brio.
Expand Down
4 changes: 3 additions & 1 deletion src/brio/src/Shared/RxBrioUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,9 @@ end
@return (source: Observable<Brio<T> | T>) -> Observable<T | U>
]=]
function RxBrioUtils.emitOnDeath(emitOnDeathValue)
return Rx.switchMap(RxBrioUtils.mapBrioToEmitOnDeathObservable(emitOnDeathValue));
return Rx.switchMap(function(brio)
return RxBrioUtils.toEmitOnDeathObservable(brio, emitOnDeathValue)
end);
end

--[=[
Expand Down
15 changes: 9 additions & 6 deletions src/brio/src/Shared/RxBrioUtils.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,17 @@ return function()
local lastResult = nil
local fireCount = 0

local sub = observe:Subscribe(function(result)
lastResult = result
fireCount = fireCount + 1
end)

it("should execute immediately", function()
local sub = observe:Subscribe(function(result)
lastResult = result
fireCount = fireCount + 1
end)
expect(fireCount).to.equal(1)
expect(lastResult).to.be.a("table")
expect(Brio.isBrio(lastResult)).to.equal(false)
expect(lastResult.value).to.equal(5)
expect(lastResult.otherValue).to.equal(25)

sub:Destroy()
end)

it("should reset when the brio is killed", function()
Expand Down Expand Up @@ -112,5 +111,9 @@ return function()
expect(lastResult.value).to.equal(75)
expect(lastResult.otherValue).to.equal(25)
end)

it("should cleanup the sub", function()
sub:Destroy()
end)
end)
end
8 changes: 4 additions & 4 deletions src/contentproviderutils/src/Client/ImageLabelLoaded.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
local require = require(script.Parent.loader).load(script)

local BaseObject = require("BaseObject")
local Promise = require("Promise")
local Signal = require("Signal")
local Maid = require("Maid")
local ContentProviderUtils = require("ContentProviderUtils")
local RxInstanceUtils = require("RxInstanceUtils")
local Maid = require("Maid")
local Promise = require("Promise")
local Rx = require("Rx")
local RxInstanceUtils = require("RxInstanceUtils")
local Signal = require("Signal")
local ValueObject = require("ValueObject")

local ImageLabelLoaded = setmetatable({}, BaseObject)
Expand Down
4 changes: 4 additions & 0 deletions src/cooldown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@
"@quenty/attributeutils": "file:../attributeutils",
"@quenty/baseobject": "file:../baseobject",
"@quenty/binder": "file:../binder",
"@quenty/ducktype": "file:../ducktype",
"@quenty/instanceutils": "file:../instanceutils",
"@quenty/loader": "file:../loader",
"@quenty/maid": "file:../maid",
"@quenty/promise": "file:../promise",
"@quenty/propertyvalue": "file:../propertyvalue",
"@quenty/remoting": "file:../remoting",
"@quenty/rx": "file:../rx",
"@quenty/rxbinderutils": "file:../rxbinderutils",
"@quenty/servicebag": "file:../servicebag",
"@quenty/signal": "file:../signal",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
local require = require(script.Parent.loader).load(script)

local CooldownBase = require("CooldownBase")
local Binder = require("Binder")

local CooldownClient = setmetatable({}, CooldownBase)
CooldownClient.ClassName = "CooldownClient"
Expand All @@ -17,14 +18,18 @@ CooldownClient.__index = CooldownClient
Constructs a new cooldown. Should be done via [CooldownBindersClient]. To create an
instance of this in Roblox, see [CooldownUtils.create].
@param obj NumberValue
@param numberValue NumberValue
@param serviceBag ServiceBag
@return Cooldown
]=]
function CooldownClient.new(obj, serviceBag)
local self = setmetatable(CooldownBase.new(obj, serviceBag), CooldownClient)
function CooldownClient.new(numberValue, serviceBag)
local self = setmetatable(CooldownBase.new(numberValue, serviceBag), CooldownClient)

self._maid:GiveTask(self.Done:Connect(function()
self._obj:Remove()
end))

return self
end

return CooldownClient
return Binder.new("Cooldown", CooldownClient)
20 changes: 0 additions & 20 deletions src/cooldown/src/Client/CooldownBindersClient.lua

This file was deleted.

22 changes: 22 additions & 0 deletions src/cooldown/src/Client/CooldownServiceClient.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--[=[
@class CooldownServiceClient
]=]

local require = require(script.Parent.loader).load(script)

local CooldownServiceClient = {}
CooldownServiceClient.ServiceName = "CooldownServiceClient"

function CooldownServiceClient:Init(serviceBag)
assert(not self._serviceBag, "Already initialized")
self._serviceBag = assert(serviceBag, "No serviceBag")

-- External
self._serviceBag:GetService(require("TimeSyncService"))

-- Internal
self._serviceBag:GetService(require("CooldownClient"))
self._serviceBag:GetService(require("CooldownShared"))
end

return CooldownServiceClient
67 changes: 0 additions & 67 deletions src/cooldown/src/Client/CooldownTracker.lua

This file was deleted.

44 changes: 44 additions & 0 deletions src/cooldown/src/Server/Binders/Cooldown.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
--[=[
Represents a cooldown state with a time limit. See [CooldownBase] for more API.
@server
@class Cooldown
]=]

local require = require(script.Parent.loader).load(script)

local CooldownBase = require("CooldownBase")
local TimeSyncService = require("TimeSyncService")
local CooldownConstants = require("CooldownConstants")
local AttributeValue = require("AttributeValue")
local Binder = require("Binder")
local PropertyValue = require("PropertyValue")

local Cooldown = setmetatable({}, CooldownBase)
Cooldown.ClassName = "Cooldown"
Cooldown.__index = Cooldown

--[=[
Constructs a new cooldown. Should be done via [Binder].
@param numberValue NumberValue
@param serviceBag ServiceBag
@return Cooldown
]=]
function Cooldown.new(numberValue, serviceBag)
local self = setmetatable(CooldownBase.new(numberValue, serviceBag), Cooldown)

self._serviceBag = assert(serviceBag, "No serviceBag")
self._syncedClock = self._serviceBag:GetService(TimeSyncService):GetSyncedClock()

self._finishTime = PropertyValue.new(self._obj, "Value")
self._startTime = AttributeValue.new(self._obj, CooldownConstants.COOLDOWN_START_TIME_ATTRIBUTE, self._syncedClock:GetTime())

self._maid:GiveTask(self.Done:Connect(function()
self._obj:Remove()
end))

return self
end

return Binder.new("Cooldown", Cooldown)
46 changes: 0 additions & 46 deletions src/cooldown/src/Server/Cooldown.lua

This file was deleted.

20 changes: 0 additions & 20 deletions src/cooldown/src/Server/CooldownBindersServer.lua

This file was deleted.

Loading

0 comments on commit c9cf806

Please sign in to comment.