@quenty/rx 3.8.0 → 4.0.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,6 +3,17 @@
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
+ # [4.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rx@3.8.0...@quenty/rx@4.0.0) (2022-03-06)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add Rx.throttleDefer() ([e0bdf7f](https://github.com/Quenty/NevermoreEngine/commit/e0bdf7f1220e66923fe275b323afd153d87f6351))
12
+
13
+
14
+
15
+
16
+
6
17
  # [3.8.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rx@3.7.1...@quenty/rx@3.8.0) (2022-01-17)
7
18
 
8
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/rx",
3
- "version": "3.8.0",
3
+ "version": "4.0.0",
4
4
  "description": "Quenty's reactive library for Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -27,16 +27,16 @@
27
27
  "Quenty"
28
28
  ],
29
29
  "dependencies": {
30
- "@quenty/loader": "^3.4.0",
30
+ "@quenty/loader": "^4.0.0",
31
31
  "@quenty/maid": "^2.1.0",
32
- "@quenty/promise": "^3.6.0",
32
+ "@quenty/promise": "^4.0.0",
33
33
  "@quenty/signal": "^2.1.0",
34
34
  "@quenty/symbol": "^2.0.1",
35
35
  "@quenty/table": "^2.1.1",
36
- "@quenty/throttle": "^3.5.0"
36
+ "@quenty/throttle": "^4.0.0"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "c094ba8f4e128cdff08919d89de226d3d65247ce"
41
+ "gitHead": "dd428cab58282c975a4c082957dc8f58e3186905"
42
42
  }
package/src/Shared/Rx.lua CHANGED
@@ -1298,4 +1298,38 @@ function Rx.throttleTime(duration, throttleConfig)
1298
1298
  end
1299
1299
  end
1300
1300
 
1301
+ --[=[
1302
+ Throttles emission of observables on the defer stack to the last emission.
1303
+ @return (source: Observable) -> Observable
1304
+ ]=]
1305
+ function Rx.throttleDefer()
1306
+ return function(source)
1307
+ assert(Observable.isObservable(source), "Bad observable")
1308
+
1309
+ return Observable.new(function(sub)
1310
+ local maid = Maid.new()
1311
+
1312
+ local lastResult
1313
+
1314
+ maid:GiveTask(source:Subscribe(function(...)
1315
+ if not lastResult then
1316
+ lastResult = table.pack(...)
1317
+
1318
+ -- Queue up our result
1319
+ task.defer(function()
1320
+ local current = lastResult
1321
+ lastResult = nil
1322
+
1323
+ sub:Fire(table.unpack(current, 1, current.n))
1324
+ end)
1325
+ else
1326
+ lastResult = table.pack(...)
1327
+ end
1328
+ end, sub:GetFailComplete()))
1329
+
1330
+ return maid
1331
+ end)
1332
+ end
1333
+ end
1334
+
1301
1335
  return Rx