@quenty/rx 13.9.0 → 13.10.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
+ # [13.10.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rx@13.9.0...@quenty/rx@13.10.0) (2024-10-23)
7
+
8
+
9
+ ### Features
10
+
11
+ * Rx.skipUntil, Rx.skipWhile, and Rx.takeWhile ([#512](https://github.com/Quenty/NevermoreEngine/issues/512)) ([5765535](https://github.com/Quenty/NevermoreEngine/commit/57655352cd1696fd1fffb8c819fb3b3a9c1c64f7))
12
+
13
+
14
+
15
+
16
+
6
17
  # [13.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rx@13.8.0...@quenty/rx@13.9.0) (2024-10-06)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/rx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/rx",
3
- "version": "13.9.0",
3
+ "version": "13.10.0",
4
4
  "description": "Quenty's reactive library for Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -41,5 +41,5 @@
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  },
44
- "gitHead": "67c5dbf46f6f45213812f3f117419a5534936a0b"
44
+ "gitHead": "7a0a75391c63d25806bfb9d266eb54994333dcfa"
45
45
  }
package/src/Shared/Rx.lua CHANGED
@@ -1947,4 +1947,100 @@ function Rx.throttle(durationSelector)
1947
1947
  end
1948
1948
  end
1949
1949
 
1950
- return Rx
1950
+ --[=[
1951
+ Skips over values emitted by the source observable until a passed-in notifier observable emits a value.
1952
+
1953
+ https://rxjs.dev/api/operators/skipUntil
1954
+
1955
+ @param notifier Observable
1956
+ @return (source: Observable) -> Observable
1957
+ ]=]
1958
+ function Rx.skipUntil(notifier)
1959
+ assert(Observable.isObservable(notifier), "Bad observable")
1960
+
1961
+ return function(source)
1962
+ assert(Observable.isObservable(source), "Bad observable")
1963
+
1964
+ return Observable.new(function(sub)
1965
+ local maid = Maid.new()
1966
+ local taking = false
1967
+
1968
+ maid._skipping = notifier:Subscribe(function()
1969
+ maid._skipping = nil
1970
+ taking = true
1971
+ end)
1972
+
1973
+ maid:GiveTask(source:Subscribe(function(...)
1974
+ if taking then
1975
+ sub:Fire(...)
1976
+ end
1977
+ end, sub:GetFailComplete()))
1978
+
1979
+ return maid
1980
+ end)
1981
+ end
1982
+ end
1983
+
1984
+ --[=[
1985
+ Skips over values emitted by the source observable as long as the given predicate is true.
1986
+
1987
+ https://rxjs.dev/api/index/function/skipWhile
1988
+
1989
+ @param predicate (index: number, ...: any) -> boolean
1990
+ @return (source: Observable) -> Observable
1991
+ ]=]
1992
+ function Rx.skipWhile(predicate)
1993
+ assert(type(predicate) == "function", "Bad predicate")
1994
+
1995
+ return function(source)
1996
+ assert(Observable.isObservable(source), "Bad observable")
1997
+
1998
+ return Observable.new(function(sub)
1999
+ local skipping = true
2000
+ local index = 0
2001
+
2002
+ return source:Subscribe(function(...)
2003
+ if not skipping then
2004
+ sub:Fire(...)
2005
+ return
2006
+ end
2007
+
2008
+ index += 1
2009
+
2010
+ skipping = predicate(index, ...)
2011
+ end, sub:GetFailComplete())
2012
+ end)
2013
+ end
2014
+ end
2015
+
2016
+ --[=[
2017
+ Emits values from the source observable as long as the given predicate is true. Completes if the predicate is false.
2018
+
2019
+ https://rxjs.dev/api/index/function/takeWhile
2020
+
2021
+ @param predicate (index: number, ...: any) -> boolean
2022
+ @return (source: Observable) -> Observable
2023
+ ]=]
2024
+ function Rx.takeWhile(predicate)
2025
+ assert(type(predicate) == "function", "Bad predicate")
2026
+
2027
+ return function(source)
2028
+ assert(Observable.isObservable(source), "Bad observable")
2029
+
2030
+ return Observable.new(function(sub)
2031
+ local index = 0
2032
+
2033
+ return source:Subscribe(function(...)
2034
+ index += 1
2035
+
2036
+ if predicate(index, ...) then
2037
+ sub:Fire(...)
2038
+ else
2039
+ sub:Complete()
2040
+ end
2041
+ end, sub:GetFailComplete())
2042
+ end)
2043
+ end
2044
+ end
2045
+
2046
+ return Rx