@quenty/teleportserviceutils 3.6.0 → 3.7.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
+ # [3.7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/teleportserviceutils@3.6.0...@quenty/teleportserviceutils@3.7.0) (2023-05-26)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add RxTeleportUtils.observeTeleportBrio(player) ([1a09a41](https://github.com/Quenty/NevermoreEngine/commit/1a09a41e220c510384ec6583ffd294874ff3c8f5))
12
+
13
+
14
+
15
+
16
+
6
17
  # [3.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/teleportserviceutils@3.5.1...@quenty/teleportserviceutils@3.6.0) (2023-04-10)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/teleportserviceutils
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/teleportserviceutils",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "description": "Utility functions for teleport srevice",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,8 +26,12 @@
26
26
  "Quenty"
27
27
  ],
28
28
  "dependencies": {
29
+ "@quenty/brio": "^8.13.0",
29
30
  "@quenty/loader": "^6.2.1",
30
- "@quenty/promise": "^6.5.0"
31
+ "@quenty/maid": "^2.5.0",
32
+ "@quenty/promise": "^6.5.0",
33
+ "@quenty/rx": "^7.11.0",
34
+ "@quenty/valueobject": "^7.14.0"
31
35
  },
32
36
  "devDependencies": {
33
37
  "@quenty/loader": "file:../loader"
@@ -35,5 +39,5 @@
35
39
  "publishConfig": {
36
40
  "access": "public"
37
41
  },
38
- "gitHead": "3306212248c310731931ad45d8b86dc7247f2a5d"
42
+ "gitHead": "11058e90e51ea83d3dad6ae9abe59cc19c36b94b"
39
43
  }
@@ -0,0 +1,60 @@
1
+ --[=[
2
+ Helps observe teleports.
3
+
4
+ @class RxTeleportUtils
5
+ ]=]
6
+
7
+ local require = require(script.Parent.loader).load(script)
8
+
9
+ local Maid = require("Maid")
10
+ local Observable = require("Observable")
11
+ local ValueObject = require("ValueObject")
12
+ local Brio = require("Brio")
13
+
14
+ local RxTeleportUtils = {}
15
+
16
+ --[=[
17
+ Returns an observable that exists for the lifetime that the player is attempting to
18
+ teleport to the given placeId.
19
+
20
+ @param player Player
21
+ @return Observable<Brio<number>>
22
+ ]=]
23
+ function RxTeleportUtils.observeTeleportBrio(player)
24
+ assert(typeof(player) == "Instance", "Bad player")
25
+
26
+ return Observable.new(function(sub)
27
+ local maid = Maid.new()
28
+
29
+ local teleportPlaceId = ValueObject.new(nil)
30
+ maid:GiveTask(teleportPlaceId)
31
+
32
+ maid:GiveTask(player.OnTeleport:Connect(function(teleportState, placeId)
33
+ if teleportState == Enum.TeleportState.RequestedFromServer
34
+ or teleportState == Enum.TeleportState.Started
35
+ or teleportState == Enum.TeleportState.WaitingForServer
36
+ or teleportState == Enum.TeleportState.InProgress then
37
+ teleportPlaceId.Value = placeId
38
+ elseif teleportState == Enum.TeleportState.Failed then
39
+ teleportPlaceId.Value = nil
40
+ else
41
+ warn(string.format("[RxTeleportUtils.observeTeleportBrio] - Unknown teleport state %s", tostring(teleportState)))
42
+ end
43
+ end))
44
+
45
+ maid:GiveTask(teleportPlaceId:Observe():Subscribe(function(placeId)
46
+ if placeId then
47
+ local brio = Brio.new(placeId)
48
+ maid._current = brio
49
+
50
+ sub:Fire(brio)
51
+ else
52
+ maid._current = nil
53
+ end
54
+ end))
55
+
56
+ return maid
57
+ end)
58
+ end
59
+
60
+ return RxTeleportUtils