@quenty/observablecollection 2.2.1-canary.261.5628274.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,7 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [2.2.1-canary.261.5628274.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/observablecollection@2.2.0...@quenty/observablecollection@2.2.1-canary.261.5628274.0) (2022-05-21)
6
+ # [3.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/observablecollection@3.0.0...@quenty/observablecollection@3.1.0) (2022-06-21)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add more API surface to ObservableMapSet ([f2ae08b](https://github.com/Quenty/NevermoreEngine/commit/f2ae08ba714e3aefc9f9bf1ae30fefc679535d2b))
12
+
13
+
14
+
15
+
16
+
17
+ # [3.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/observablecollection@2.2.0...@quenty/observablecollection@3.0.0) (2022-05-21)
7
18
 
8
19
 
9
20
  ### Features
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2014-2021 Quenty
3
+ Copyright (c) 2014-2022 Quenty
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/observablecollection",
3
- "version": "2.2.1-canary.261.5628274.0",
3
+ "version": "3.1.0",
4
4
  "description": "An observable set",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -27,17 +27,17 @@
27
27
  "Quenty"
28
28
  ],
29
29
  "dependencies": {
30
- "@quenty/brio": "5.2.1-canary.261.5628274.0",
31
- "@quenty/loader": "4.1.1-canary.261.5628274.0",
32
- "@quenty/maid": "2.3.0",
33
- "@quenty/promise": "4.2.1-canary.261.5628274.0",
34
- "@quenty/rx": "4.2.1-canary.261.5628274.0",
35
- "@quenty/signal": "2.2.0",
36
- "@quenty/symbol": "2.1.0",
37
- "@quenty/valuebaseutils": "4.2.1-canary.261.5628274.0"
30
+ "@quenty/brio": "^6.1.0",
31
+ "@quenty/loader": "^5.0.0",
32
+ "@quenty/maid": "^2.3.0",
33
+ "@quenty/promise": "^5.0.0",
34
+ "@quenty/rx": "^5.1.0",
35
+ "@quenty/signal": "^2.2.0",
36
+ "@quenty/symbol": "^2.1.0",
37
+ "@quenty/valuebaseutils": "^5.1.0"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "5628274461f4fa0135e63b62e99fcd508d4c94f9"
42
+ "gitHead": "c8732cc5dea767b3ff362db43137e2a16da7bc0d"
43
43
  }
@@ -165,6 +165,21 @@ function ObservableList:ObserveIndexByKey(key)
165
165
  end)
166
166
  end
167
167
 
168
+ --[=[
169
+ Gets the current index from the key
170
+
171
+ @param key Symbol
172
+ @return number
173
+ ]=]
174
+ function ObservableList:GetIndexByKey(key)
175
+ local currentIndex = self._indexes[key]
176
+ if currentIndex then
177
+ return currentIndex
178
+ else
179
+ return nil
180
+ end
181
+ end
182
+
168
183
  --[=[
169
184
  Gets the count of items in the list
170
185
  @return number
@@ -11,6 +11,8 @@ local Maid = require("Maid")
11
11
  local Observable = require("Observable")
12
12
  local ObservableSet = require("ObservableSet")
13
13
  local Signal = require("Signal")
14
+ local Brio = require("Brio")
15
+ local RxBrioUtils = require("RxBrioUtils")
14
16
 
15
17
  local ObservableMapSet = {}
16
18
  ObservableMapSet.ClassName = "ObservableMapSet"
@@ -52,7 +54,7 @@ end
52
54
  that need to be looked up by key.
53
55
 
54
56
  @param entry TValue
55
- @param observeKey Observable<Brio<TKey>>
57
+ @param observeKey Observable<TKey>
56
58
  ]=]
57
59
  function ObservableMapSet:Add(entry, observeKey)
58
60
  local maid = Maid.new()
@@ -125,6 +127,8 @@ function ObservableMapSet:ObserveItemsForKeyBrio(key)
125
127
  end
126
128
 
127
129
  function ObservableMapSet:GetListForKey(key)
130
+ assert(key ~= nil, "Bad key")
131
+
128
132
  local observableSet = self._observableSetMap[key]
129
133
  if not observableSet then
130
134
  return {}
@@ -134,9 +138,58 @@ function ObservableMapSet:GetListForKey(key)
134
138
  end
135
139
 
136
140
  function ObservableMapSet:GetObservableSetForKey(key)
141
+ assert(key ~= nil, "Bad key")
142
+
137
143
  return self._observableSetMap[key]
138
144
  end
139
145
 
146
+ function ObservableMapSet:ObserveSetBrio(key)
147
+ assert(key ~= nil, "Bad key")
148
+
149
+ return Observable.new(function(sub)
150
+ local topMaid = Maid.new()
151
+
152
+ local function connect()
153
+ local brio
154
+
155
+ local set = self._observableSetMap[key]
156
+ if set then
157
+ brio = Brio.new(set)
158
+ sub:Fire(brio)
159
+ end
160
+
161
+ topMaid._current = brio
162
+ end
163
+
164
+ topMaid:GiveTask(self.SetAdded:Connect(function(addedKey)
165
+ if addedKey == key then
166
+ connect()
167
+ end
168
+ end))
169
+
170
+ topMaid:GiveTask(self.SetRemoved:Connect(function(removedKey)
171
+ if removedKey == key then
172
+ connect()
173
+ end
174
+ end))
175
+
176
+ connect()
177
+
178
+ return topMaid
179
+ end)
180
+ end
181
+
182
+ function ObservableMapSet:ObserveCountForKey(key)
183
+ assert(key ~= nil, "Bad key")
184
+
185
+ return self:ObserveSetBrio(key):Pipe({
186
+ RxBrioUtils.switchMapBrio(function(observableSet)
187
+ return observableSet:ObserveCount()
188
+ end);
189
+ RxBrioUtils.emitOnDeath(0);
190
+ })
191
+ end
192
+
140
193
  function ObservableMapSet:_addToObservableSet(key, entry)
141
194
  local set = self:_getOrCreateObservableSet(key)
142
195
  set:Add(entry)