@quenty/playerutils 2.4.0 → 2.5.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 +11 -0
- package/package.json +4 -4
- package/src/Shared/RxPlayerUtils.lua +27 -2
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
|
+
# [2.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/playerutils@2.4.0...@quenty/playerutils@2.5.0) (2023-01-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add RxPlayerUtils.observePlayers(predicate) ([2958baa](https://github.com/Quenty/NevermoreEngine/commit/2958baa6b5c0055b5e965b832be65dda5b4a685a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [2.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/playerutils@2.3.1...@quenty/playerutils@2.4.0) (2023-01-01)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/playerutils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/playerutils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Player utility functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@quenty/brio": "^8.
|
|
31
|
+
"@quenty/brio": "^8.4.0",
|
|
32
32
|
"@quenty/loader": "^6.0.1",
|
|
33
|
-
"@quenty/rx": "^7.
|
|
33
|
+
"@quenty/rx": "^7.4.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "db2db00ab4e24a3eab0449b77a00bee6d91f2755"
|
|
36
36
|
}
|
|
@@ -15,10 +15,10 @@ local RxPlayerUtils = {}
|
|
|
15
15
|
|
|
16
16
|
--[=[
|
|
17
17
|
Observe players for the lifetime they exist
|
|
18
|
-
@param predicate
|
|
18
|
+
@param predicate callback
|
|
19
19
|
@return Observable<Brio<Player>>
|
|
20
20
|
]=]
|
|
21
|
-
function RxPlayerUtils.observePlayersBrio(predicate: (Player) -> boolean
|
|
21
|
+
function RxPlayerUtils.observePlayersBrio(predicate: (Player) -> boolean)
|
|
22
22
|
assert(type(predicate) == "function" or predicate == nil, "Bad predicate!")
|
|
23
23
|
|
|
24
24
|
return Observable.new(function(sub)
|
|
@@ -47,4 +47,29 @@ function RxPlayerUtils.observePlayersBrio(predicate: (Player) -> boolean?)
|
|
|
47
47
|
end)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
+
--[=[
|
|
51
|
+
Observe players as they're added, and as they are.
|
|
52
|
+
@param predicate callback
|
|
53
|
+
@return Observable<Player>
|
|
54
|
+
]=]
|
|
55
|
+
function RxPlayerUtils.observePlayers(predicate: (Player) -> boolean)
|
|
56
|
+
return Observable.new(function(sub)
|
|
57
|
+
local maid = Maid.new()
|
|
58
|
+
|
|
59
|
+
local function handlePlayer(player)
|
|
60
|
+
if predicate == nil or predicate(player) then
|
|
61
|
+
sub:Fire(player)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
maid:GiveTask(Players.PlayerAdded:Connect(handlePlayer))
|
|
66
|
+
|
|
67
|
+
for _, player in Players:GetPlayers() do
|
|
68
|
+
handlePlayer(player)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
return maid
|
|
72
|
+
end)
|
|
73
|
+
end
|
|
74
|
+
|
|
50
75
|
return RxPlayerUtils
|