Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/validark/rbxready
A way to wait until an object has been fully loaded
https://github.com/validark/rbxready
Last synced: 5 days ago
JSON representation
A way to wait until an object has been fully loaded
- Host: GitHub
- URL: https://github.com/validark/rbxready
- Owner: Validark
- License: mit
- Created: 2018-07-07T17:38:33.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-07T17:40:26.000Z (over 6 years ago)
- Last Synced: 2024-10-30T21:12:58.490Z (about 2 months ago)
- Language: Lua
- Size: 11.7 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RbxReady
A Library for yielding until an object's descendants have finished replicating. This is still imperfect, but it seems to be the best option if you want this kind of functionality.# Usage
Example code:
```lua
local Ready = require(script.Ready)Ready:Wait(workspace, 10)
Ready:Connect(workspace, function(LastToLoad)
print("Workspace has been fully loaded - the last instance to load was", LastToLoad)
end)
```There is a single config variable in the module called `TIMEOUT`. This is the default number of seconds the script will wait where no descendants have been added to deem the object loaded.
The timeout value that gets used is essentially the minimum amount of time possible for an object to be fully loaded. This means that if the timeout is set to 1 (second), it will always take at least 1 second for an object to load.
# API
### *void* Ready:Wait(*instance* Object [, *number* Timeout])Repeatedly calls `wait()` until the timeout has been reached and no descendants of the `Object` were added in that time.
### *RBXScriptConnection* Ready:Connect(*instance* Object, *function* Callback [, *number* Timeout])
Completes the timeout after every time a descendant of `Object` was added, then calls `Callback` if no other descendants had been added in the wait time. Returns a `RBXScriptConnection` which can be disconnected at any time, and is disconnected after the object has loaded.
The `Callback` function may take one argument; this being the last descendant that was added. Will be `nil` if no descendants were added.