Skip to content

Commit

Permalink
update promise lib
Browse files Browse the repository at this point in the history
  • Loading branch information
dig1t committed Jun 24, 2024
1 parent babdfcc commit 5e5b441
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"luau-lsp.diagnostics.workspace": true,
"luau-lsp.require.mode": "relativeToFile",
"luau-lsp.require.mode": "relativeToWorkspaceRoot",
"luau-lsp.sourcemap.autogenerate": true,
"luau-lsp.sourcemap.enabled": true,
"luau-lsp.sourcemap.rojoProjectFile": "dev.project.json",
Expand Down
6 changes: 3 additions & 3 deletions src/Store.luau
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local Types = require(script.Parent.Types)
local Util = require(script.Parent.Parent.Util)
local redUtil = require(script.Parent.redUtil)

local remotes: any = redUtil.getRemotes()
local remotes = redUtil.getRemotes()
local isServer: boolean = RunService:IsServer()

local Store = {}
Expand Down Expand Up @@ -170,7 +170,7 @@ function Store.get(self: StoreType, action: Types.Action): any
end)
:finally(function()
for _, connection: RBXScriptConnection in pairs(connections) do
connection:Disconnect() -- Disconnect the watcher
connection:Disconnect() -- Disconnect the watchers
end
end)

Expand All @@ -182,7 +182,7 @@ function Store.get(self: StoreType, action: Types.Action): any
until res ~= nil or responseReceived or os.clock() - start >= timeout

if not responseReceived then
promise:reject(`Timed out while waiting for action: "{action.type}"`)
promise:_reject(`Timed out while waiting for action: "{action.type}"`)
end

return res
Expand Down
40 changes: 24 additions & 16 deletions src/redUtil.luau
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,37 @@ local Constants = require(script.Parent.Constants)

local Util = {}

function Util.getRemotes()
function Util.getRemotes(): { Client: RemoteEvent, Server: BindableEvent }
local remotes = RunService:IsClient() and ReplicatedStorage:WaitForChild(Constants.REMOTE_FOLDER_NAME)
or ReplicatedStorage:FindFirstChild(Constants.REMOTE_FOLDER_NAME)

if not remotes then
-- Container for remotes
remotes = Instance.new("Folder")
remotes.Name = Constants.REMOTE_FOLDER_NAME
if remotes then
return {
Client = remotes:WaitForChild("Client", 60) :: RemoteEvent,
Server = remotes:WaitForChild("Server", 60) :: BindableEvent,
}
end

-- store:dispatch() calls from client to server and server to client
local client: RemoteEvent = Instance.new("RemoteEvent")
client.Name = "Client"
client.Parent = remotes
-- Container for remotes
local newRemotes = Instance.new("Folder")
newRemotes.Name = Constants.REMOTE_FOLDER_NAME

-- store:dispatch() calls from server to server
local server: BindableEvent = Instance.new("BindableEvent")
server.Name = "Server"
server.Parent = remotes
-- store:dispatch() calls from client to server and server to client
local client: RemoteEvent = Instance.new("RemoteEvent")
client.Name = "Client"
client.Parent = newRemotes

remotes.Parent = ReplicatedStorage
end
-- store:dispatch() calls from server to server
local server: BindableEvent = Instance.new("BindableEvent")
server.Name = "Server"
server.Parent = newRemotes

newRemotes.Parent = ReplicatedStorage

return remotes
return {
Client = client,
Server = server,
}
end

return Util
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.8
1.4.9
4 changes: 2 additions & 2 deletions wally.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ include = ["src", "default.project.json"]
exclude = ["src/**/*.spec.luau"]

[dependencies]
Util = "dig1t/[email protected].3"
Promise = "dig1t/promise@1.0.1"
Util = "dig1t/[email protected].6"
Promise = "dig1t/promise@1.1.0"

0 comments on commit 5e5b441

Please sign in to comment.