Skip to content

Commit

Permalink
fix: Fix :Observe() method in ObservableSortedList
Browse files Browse the repository at this point in the history
fix: Fix :Observe() method in ObservableSortedList
  • Loading branch information
Quenty authored Nov 13, 2024
2 parents 9c3afd1 + 7414df3 commit 2c09fbc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ local require = require(script.Parent.loader).load(script)

local Brio = require("Brio")
local DuckTypeUtils = require("DuckTypeUtils")
local ListIndexUtils = require("ListIndexUtils")
local Maid = require("Maid")
local Observable = require("Observable")
local ObservableSubscriptionTable = require("ObservableSubscriptionTable")
local Rx = require("Rx")
local Signal = require("Signal")
local SortedNode = require("SortedNode")
local SortedNodeValue = require("SortedNodeValue")
local ValueObject = require("ValueObject")
local SortFunctionUtils = require("SortFunctionUtils")
local ListIndexUtils = require("ListIndexUtils")
local ValueObject = require("ValueObject")

local ObservableSortedList = {}
ObservableSortedList.ClassName = "ObservableSortedList"
Expand Down Expand Up @@ -116,7 +116,11 @@ end
@return Observable<{ T }>
]=]
function ObservableSortedList:Observe()
return self._mainObservables:Observe("list")
return self._mainObservables:Observe("list"):Pipe({
Rx.start(function()
return self:GetList()
end)
})
end

--[=[
Expand Down
5 changes: 2 additions & 3 deletions src/rx/src/Shared/Rx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1448,27 +1448,26 @@ function Rx.combineLatest(observables)
assert(type(observables) == "table", "Bad observables")

return Observable.new(function(sub)
local pending = 0
local unset = 0
local latest = {}

-- Instead of caching this, use extra compute here
for key, value in pairs(observables) do
if Observable.isObservable(value) then
pending += 1
unset += 1
latest[key] = UNSET_VALUE
else
latest[key] = value
end
end

if pending == 0 then
if unset == 0 then
sub:Fire(latest)
sub:Complete()
return
end

local pending = unset
local maid = Maid.new()

local function failOnFirst(...)
Expand Down
1 change: 1 addition & 0 deletions src/settings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@quenty/datastore": "file:../datastore",
"@quenty/ducktype": "file:../ducktype",
"@quenty/enumutils": "file:../enumutils",
"@quenty/instanceutils": "file:../instanceutils",
"@quenty/jsonutils": "file:../jsonutils",
"@quenty/loader": "file:../loader",
"@quenty/maid": "file:../maid",
Expand Down
11 changes: 11 additions & 0 deletions src/table/src/Shared/Table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,17 @@ function Table.readonly(target)
return table.freeze(setmetatable(target, READ_ONLY_METATABLE))
end

--[=[
Sets a metatable on a table such that it errors when
indexing a nil value
@param target table -- Table to error on indexing
@return table -- The same table, with the target set to error on nil
]=]
function Table.errorOnNilIndex(target)
return setmetatable(target, READ_ONLY_METATABLE)
end

--[=[
Recursively sets the table as ReadOnly
Expand Down
3 changes: 2 additions & 1 deletion src/templateprovider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"@quenty/promise": "file:../promise",
"@quenty/promisemaid": "file:../promisemaid",
"@quenty/rx": "file:../rx",
"@quenty/string": "file:../string"
"@quenty/string": "file:../string",
"@quenty/table": "file:../table"
},
"publishConfig": {
"access": "public"
Expand Down

0 comments on commit 2c09fbc

Please sign in to comment.