@quenty/remoting 3.3.0 → 3.4.0-canary.241.a4e8214.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,22 @@
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.4.0-canary.241.a4e8214.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/remoting@3.3.1...@quenty/remoting@3.4.0-canary.241.a4e8214.0) (2022-01-03)
7
+
8
+ **Note:** Version bump only for package @quenty/remoting
9
+
10
+
11
+
12
+
13
+
14
+ ## [3.3.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/remoting@3.3.0...@quenty/remoting@3.3.1) (2021-12-30)
15
+
16
+ **Note:** Version bump only for package @quenty/remoting
17
+
18
+
19
+
20
+
21
+
6
22
  # [3.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/remoting@3.2.0...@quenty/remoting@3.3.0) (2021-12-18)
7
23
 
8
24
  **Note:** Version bump only for package @quenty/remoting
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  ## Remoting
2
2
  <div align="center">
3
- <a href="http://quenty.github.io/api/">
4
- <img src="https://img.shields.io/badge/docs-website-green.svg" alt="Documentation" />
3
+ <a href="http://quenty.github.io/NevermoreEngine/">
4
+ <img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/docs.yml/badge.svg" alt="Documentation status" />
5
5
  </a>
6
6
  <a href="https://discord.gg/mhtGUS8">
7
- <img src="https://img.shields.io/badge/discord-nevermore-blue.svg" alt="Discord" />
7
+ <img src="https://img.shields.io/discord/385151591524597761?color=5865F2&label=discord&logo=discord&logoColor=white" alt="Discord" />
8
8
  </a>
9
9
  <a href="https://github.com/Quenty/NevermoreEngine/actions">
10
10
  <img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/build.yml/badge.svg" alt="Build and release status" />
@@ -13,6 +13,8 @@
13
13
 
14
14
  Provides global remoting functionality for Roblox (GetRemoteEvent/GetRemoteFunction). This is extremely light-weight, but makes programming with global remotes a lot easier.
15
15
 
16
+ <div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/GetRemoteEvent">View docs →</a></div>
17
+
16
18
  ## Installation
17
19
  ```
18
20
  npm install @quenty/remoting --save
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/remoting",
3
- "version": "3.3.0",
3
+ "version": "3.4.0-canary.241.a4e8214.0",
4
4
  "description": "Global remoting retrieval system for Roblox (RemoteFunctions/RemoteEvents)",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,12 +26,12 @@
26
26
  "Quenty"
27
27
  ],
28
28
  "dependencies": {
29
- "@quenty/loader": "^3.1.1",
30
- "@quenty/promise": "^3.3.0",
31
- "@quenty/table": "^2.1.0"
29
+ "@quenty/loader": "3.2.0-canary.241.a4e8214.0",
30
+ "@quenty/promise": "3.4.0-canary.241.a4e8214.0",
31
+ "@quenty/table": "2.1.1"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "6eb398e9fb81191f0815885f807ab0cb3bb9bad1"
36
+ "gitHead": "a4e821471f35998d63f38a4f4a578e07b4e79035"
37
37
  }
@@ -1,5 +1,41 @@
1
- --- Provides getting remote events
2
- -- @function GetRemoteEvent
1
+ --[=[
2
+ Provides getting named global [RemoteEvent] resources.
3
+ @class GetRemoteEvent
4
+ ]=]
5
+
6
+ --[=[
7
+ Retrieves a global remote event from the store. On the server, it constructs a new one,
8
+ and on the client, it waits for it to exist.
9
+
10
+ :::tip
11
+ Consider using [PromiseGetRemoteEvent] for a non-yielding version
12
+ :::
13
+
14
+ ```lua
15
+ -- server.lua
16
+ local GetRemoteEvent = require("GetRemoteEvent")
17
+
18
+ local remoteEvent = GetRemoteEvent("testing")
19
+ remoteEvent.OnServerEvent:Connect(print)
20
+
21
+ -- client.lua
22
+ local GetRemoteEvent = require("GetRemoteEvent")
23
+
24
+ local remoteEvent = GetRemoteEvent("testing")
25
+ remoteEvent:FireServer("Hello") --> Hello (on the server)
26
+ ```
27
+
28
+ :::info
29
+ If the game is not running, then a mock remote event will be created
30
+ for use in testing.
31
+ :::
32
+
33
+ @yields
34
+ @function GetRemoteEvent
35
+ @within GetRemoteEvent
36
+ @param name string
37
+ @return RemoteEvent
38
+ ]=]
3
39
 
4
40
  local require = require(script.Parent.loader).load(script)
5
41
 
@@ -1,5 +1,44 @@
1
- --- Provides getting remote events
2
- -- @function GetRemoteFunction
1
+ --[=[
2
+ Provides getting named global [RemoteFunction] resources.
3
+
4
+ @class GetRemoteFunction
5
+ ]=]
6
+
7
+ --[=[
8
+ Retrieves a global remote function from the store. On the server, it constructs a new one,
9
+ and on the client, it waits for it to exist.
10
+
11
+ :::tip
12
+ Consider using [PromiseGetRemoteFunction] for a non-yielding version
13
+ :::
14
+
15
+ ```lua
16
+ -- server.lua
17
+ local GetRemoteFunction = require("GetRemoteFunction")
18
+
19
+ local remoteFunction = GetRemoteFunction("testing")
20
+ remoteFunction.OnServerInvoke = function(_player, text)
21
+ return "HI " .. tostring(text)
22
+ end
23
+
24
+ -- client.lua
25
+ local GetRemoteFunction = require("GetRemoteFunction")
26
+
27
+ local remoteFunction = GetRemoteFunction("testing")
28
+ print(remoteFunction:InvokeServer("Bob")) --> HI Bob
29
+ ```
30
+
31
+ :::info
32
+ If the game is not running, then a mock remote event will be created
33
+ for use in testing.
34
+ :::
35
+
36
+ @yields
37
+ @function GetRemoteFunction
38
+ @within GetRemoteFunction
39
+ @param name string
40
+ @return RemoteFunction
41
+ ]=]
3
42
 
4
43
  local require = require(script.Parent.loader).load(script)
5
44
 
@@ -1,5 +1,7 @@
1
- --- Retrieves a remote event as a promise
2
- -- @module PromiseGetRemoteEvent
1
+ --[=[
2
+ Retrieves a remote event as a promise
3
+ @class PromiseGetRemoteEvent
4
+ ]=]
3
5
 
4
6
  local require = require(script.Parent.loader).load(script)
5
7
 
@@ -10,6 +12,14 @@ local GetRemoteEvent = require("GetRemoteEvent")
10
12
  local Promise = require("Promise")
11
13
  local ResourceConstants = require("ResourceConstants")
12
14
 
15
+ --[=[
16
+ Like [GetRemoteEvent] but in promise form.
17
+
18
+ @function PromiseGetRemoteEvent
19
+ @within PromiseGetRemoteEvent
20
+ @param name string
21
+ @return Promise<RemoteEvent>
22
+ ]=]
13
23
  if not RunService:IsRunning() then
14
24
  -- Handle testing
15
25
  return function(name)
@@ -1,5 +1,7 @@
1
- --- Retrieves a remote function as a promise
2
- -- @module PromiseGetRemoteFunction
1
+ --[=[
2
+ Retrieves a remote function as a promise
3
+ @class PromiseGetRemoteFunction
4
+ ]=]
3
5
 
4
6
  local require = require(script.Parent.loader).load(script)
5
7
 
@@ -10,6 +12,15 @@ local GetRemoteFunction = require("GetRemoteFunction")
10
12
  local Promise = require("Promise")
11
13
  local ResourceConstants = require("ResourceConstants")
12
14
 
15
+ --[=[
16
+ Like [GetRemoteFunction] but in promise form.
17
+
18
+ @function PromiseGetRemoteFunction
19
+ @within PromiseGetRemoteFunction
20
+ @param name string
21
+ @return Promise<RemoteFunction>
22
+ ]=]
23
+
13
24
  if not RunService:IsRunning() then
14
25
  -- Handle testing
15
26
  return function(name)
@@ -1,5 +1,7 @@
1
- --- Intended for classes that extend BaseObject only
2
- -- @module PromiseRemoteEventMixin
1
+ --[=[
2
+ Intended for classes that extend BaseObject only
3
+ @class PromiseRemoteEventMixin
4
+ ]=]
3
5
 
4
6
  local require = require(script.Parent.loader).load(script)
5
7
 
@@ -7,8 +9,37 @@ local promiseChild = require("promiseChild")
7
9
 
8
10
  local PromiseRemoteEventMixin = {}
9
11
 
12
+ --[=[
13
+ Adds the remote function mixin to a class
14
+
15
+ ```lua
16
+ local BaseObject = require("BaseObject")
17
+
18
+ local Bird = setmetatable({}, BaseObject)
19
+ Bird.ClassName = "Bird"
20
+ Bird.__index = Bird
21
+
22
+ require("PromiseRemoteEventMixin"):Add(Bird, "BirdRemoteEvent")
23
+
24
+ function Bird.new(inst)
25
+ local self = setmetatable(BaseObject.new(inst), Bird)
26
+
27
+ self:PromiseRemoteEvent():Then(function(remoteEvent)
28
+ self._maid:GiveTask(remoteEvent.OnClientEvent:Connect(function(...)
29
+ self:_handleRemoteEvent(...)
30
+ end)
31
+ end)
32
+
33
+ return self
34
+ end
35
+ ```
36
+
37
+ @param class { _maid: Maid }
38
+ @param remoteEventName string
39
+ ]=]
10
40
  function PromiseRemoteEventMixin:Add(class, remoteEventName)
11
- assert(remoteEventName, "Bad remoteEventName")
41
+ assert(type(class) == "table", "Bad class")
42
+ assert(type(remoteEventName) == "string", "Bad remoteEventName")
12
43
  assert(not class.PromiseRemoteEventMixin, "Class already has PromiseRemoteEventMixin defined")
13
44
  assert(not class._remoteEventName, "Class already has _remoteEventName defined")
14
45
 
@@ -16,7 +47,10 @@ function PromiseRemoteEventMixin:Add(class, remoteEventName)
16
47
  class._remoteEventName = remoteEventName
17
48
  end
18
49
 
19
- -- Initialize PromiseRemoteEventMixin
50
+ --[=[
51
+ Returns a promise that returns a remote event
52
+ @return Promise<RemoteEvent>
53
+ ]=]
20
54
  function PromiseRemoteEventMixin:PromiseRemoteEvent()
21
55
  return self._maid:GivePromise(promiseChild(self._obj, self._remoteEventName))
22
56
  end
@@ -1,5 +1,7 @@
1
- --- Intended for classes that extend BaseObject only
2
- -- @module PromiseRemoteFunctionMixin
1
+ --[=[
2
+ Intended for classes that extend BaseObject only
3
+ @class PromiseRemoteFunctionMixin
4
+ ]=]
3
5
 
4
6
  local require = require(script.Parent.loader).load(script)
5
7
 
@@ -7,8 +9,37 @@ local promiseChild = require("promiseChild")
7
9
 
8
10
  local PromiseRemoteFunctionMixin = {}
9
11
 
12
+ --[=[
13
+ Adds the remote function mixin to a class
14
+
15
+ ```lua
16
+ local BaseObject = require("BaseObject")
17
+
18
+ local Bird = setmetatable({}, BaseObject)
19
+ Bird.ClassName = "Bird"
20
+ Bird.__index = Bird
21
+
22
+ require("PromiseRemoteFunctionMixin"):Add(Bird, "BirdRemoteFunction")
23
+
24
+ function Bird.new(inst)
25
+ local self = setmetatable(BaseObject.new(inst), Bird)
26
+
27
+ self:PromiseRemoteFunction():Then(function(remoteFunction)
28
+ task.spawn(function()
29
+ remoteFunction:InvokeServer() -- or whatever
30
+ end)
31
+ end)
32
+
33
+ return self
34
+ end
35
+ ```
36
+
37
+ @param class { _maid: Maid }
38
+ @param remoteFunctionName string
39
+ ]=]
10
40
  function PromiseRemoteFunctionMixin:Add(class, remoteFunctionName)
11
- assert(remoteFunctionName, "Bad remoteFunctionName")
41
+ assert(type(class) == "table", "Bad class")
42
+ assert(type(remoteFunctionName) == "string", "Bad remoteFunctionName")
12
43
  assert(not class.PromiseRemoteFunctionMixin, "Class already has PromiseRemoteFunctionMixin defined")
13
44
  assert(not class._remoteFunctionName, "Class already has _remoteFunctionName defined")
14
45
 
@@ -16,7 +47,10 @@ function PromiseRemoteFunctionMixin:Add(class, remoteFunctionName)
16
47
  class._remoteFunctionName = remoteFunctionName
17
48
  end
18
49
 
19
- -- Initialize PromiseRemoteFunctionMixin
50
+ --[=[
51
+ Returns a promise that returns a remote function
52
+ @return Promise<RemoteFunction>
53
+ ]=]
20
54
  function PromiseRemoteFunctionMixin:PromiseRemoteFunction()
21
55
  return self._maid:GivePromise(promiseChild(self._obj, self._remoteFunctionName))
22
56
  end
@@ -1,5 +1,8 @@
1
- --- Holds constants for resource retrieval
2
- -- @module ResourceConstants
1
+ --[=[
2
+ Holds constants for resource retrieval.
3
+ @class ResourceConstants
4
+ @private
5
+ ]=]
3
6
 
4
7
  local require = require(script.Parent.loader).load(script)
5
8