Skip to main content

ContentProviderQueue

A simple class for working with ContentProvider.

local contentProviderQueue = ContentProviderQueue.new()
contentProviderQueue:addInstances({sound1, sound2, sound3})
print(#contentProviderQueue:pendingInstances()) --> 3
contentProviderQueue:fullyProgressed():await() -- ensure all pending instances are preloaded
print(#contentProviderQueue:pendingInstances()) --> 0

Types

ContentProviderQueue

type ContentProviderQueue = ContentProviderQueue

Properties

onInstancePreloaded

Read onlySignalContentProviderQueue Instance
ContentProviderQueue.onInstancePreloaded: Signal<instanceInstance,contentProviderIdstring,deltaTimenumber,statusEnum.AssetFetchStatus>

A signal which is fired whenever an instance in the content provider queue has been preloaded.

deltaTime is the amount of time the instance took to be preloaded.

onInstancePreloading

Read onlySignalContentProviderQueue Instance
ContentProviderQueue.onInstancePreloading: Signal<instanceInstance>

A signal which is fired whenever an instance in the content provider queue is being preloaded.

onInstanceAdded

Read onlySignalContentProviderQueue Instance
ContentProviderQueue.onInstanceAdded: Signal<instanceInstance>

A signal which is fired whenever an instance is added to the content provider queue.

onInstanceRemoved

Read onlySignalContentProviderQueue Instance
ContentProviderQueue.onInstanceRemoved: Signal<instanceInstance>

A signal which is fired whenever an instance is removed from the content provider queue.

Functions

new

ContentProviderQueue.new(initialUpdateIntervalnumber?) → ContentProviderQueue

Creates a new content preloader queue. An initialUpdateInterval argument can be passed as the initial update interval of the queue.

is

ContentProviderQueue.is(selfany) → boolean

Returns a boolean indicating whether or not self is a ContentProviderQueue object or not.

setUpdateInterval

ContentProviderQueue:setUpdateInterval(updateIntervalnumber) → ()

Sets the update interval of the queue, i.e the interval at which the queue will preload each asset.

add

ContentProviderQueue:add(instanceInstance) → ()

Adds the given instance to the content provider queue. If the given instance already exists, then the instance will not be readded again.

addInstances

ContentProviderQueue:addInstances(instances{Instance}) → ()

Adds all instances in instances to the content provider queue, via ContentProviderQueue:add.

remove

ContentProviderQueue:remove(instanceInstance) → ()

Removes the instance from the given queue, if the instance was being preloaded, then it will be disregarded by the content provider queue.

local contentProviderQueue = ...
contentProviderQueue:add(sound1)
print(#contentProviderQueue:pendingInstances()) --> 1
contentProviderQueue:remove(sound1)
print(pendingInstancescontentProviderQueue:pendingInstances()) --> 0

progress

ContentProviderQueue:progress() → number

Returns a number from 0 to 1 indicating the progress of the content provider queue (i.e ratio of how many instances have been preloaded versus how many instances are yet to be preloaded).

fullyProgressed

ContentProviderQueue:fullyProgressed() → Promise<>

Returns a promise which is resolved once the content provider queue has fully progressed, i.e there are no more instances to preload.

paused

ContentProviderQueue:paused() → boolean

Returns a boolean indicating if the content provider queue is paused or not.

resume

ContentProviderQueue:resume() → ()

Resumes the content provider queue.

pause

ContentProviderQueue:pause() → ()

Pauses the content provider queue. If any more instances are to be preloaded, they won't be until the content provider object is resumed back.

removeAll

ContentProviderQueue:removeAll() → ()

Clears all instances to be preloaded from the content provider queue, via ContentProviderQueue:remove.

pendingInstances

ContentProviderQueue:pendingInstances() → {Instance}

Returns a read only array of all instances, yet to be preloaded in the content provider queue.

destroy

ContentProviderQueue:destroy() → ()

Destroys the content provider queue, empties it through ContentProviderQueue:empty and renders it unusable.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Creates a new content preloader queue. An `initialUpdateInterval` argument can be passed\nas the initial update interval of the queue.",
            "params": [
                {
                    "name": "initialUpdateInterval",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ContentProviderQueue"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 87,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "is",
            "desc": "Returns a boolean indicating whether or not `self` is a [ContentProviderQueue] object or not.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 111,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "setUpdateInterval",
            "desc": "Sets the update interval of the queue, i.e the interval at which the queue will preload\neach asset.",
            "params": [
                {
                    "name": "updateInterval",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 120,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "add",
            "desc": "Adds the given instance to the content provider queue. If the given instance\nalready exists, then the instance **will not** be readded again.",
            "params": [
                {
                    "name": "instance",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 129,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "addInstances",
            "desc": "Adds all instances in `instances` to the content provider queue, via [ContentProviderQueue:add].",
            "params": [
                {
                    "name": "instances",
                    "desc": "",
                    "lua_type": "{ Instance }"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 143,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "remove",
            "desc": "Removes the instance from the given queue, if the instance was being preloaded, then it\nwill be disregarded by the content provider queue.\n\n```lua\nlocal contentProviderQueue = ...\ncontentProviderQueue:add(sound1)\nprint(#contentProviderQueue:pendingInstances()) --> 1\ncontentProviderQueue:remove(sound1)\nprint(pendingInstancescontentProviderQueue:pendingInstances()) --> 0\n```",
            "params": [
                {
                    "name": "instance",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 162,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "progress",
            "desc": "Returns a number from `0` to `1` indicating the progress of the content provider queue (i.e ratio\nof how many instances have been preloaded versus how many instances are *yet* to be preloaded).",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 183,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "fullyProgressed",
            "desc": "Returns a [promise](https://eryn.io/roblox-lua-promise/) which is resolved once the content provider queue\nhas fully progressed, i.e there are no more instances to preload.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 202,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "paused",
            "desc": "Returns a boolean indicating if the content provider queue is paused or not.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 216,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "resume",
            "desc": "Resumes the content provider queue.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 224,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "pause",
            "desc": "Pauses the content provider queue. If any more instances are to be preloaded, they won't be\nuntil the content provider object is resumed back. ",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 233,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "removeAll",
            "desc": "Clears all instances to be preloaded from the content provider queue, via [ContentProviderQueue:remove].",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 241,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "pendingInstances",
            "desc": "Returns a read only array of all instances, yet to be preloaded in the content provider queue.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ Instance }\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 251,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "destroy",
            "desc": "Destroys the content provider queue, empties it through [ContentProviderQueue:empty] and renders\nit unusable.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 260,
                "path": "src/ContentProviderQueue/init.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "onInstancePreloaded",
            "desc": " \n\nA [signal](https://sleitnick.github.io/RbxUtil/api/Signal/) which is fired whenever an instance in the content provider\nqueue has been preloaded.\n\n`deltaTime` is the amount of time the instance took to be preloaded.",
            "lua_type": "Signal <instance: Instance, contentProviderId: string, deltaTime: number, status: Enum.AssetFetchStatus>",
            "tags": [
                "Read only",
                "Signal",
                "ContentProviderQueue Instance"
            ],
            "source": {
                "line": 27,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "onInstancePreloading",
            "desc": " \n\nA [signal](https://sleitnick.github.io/RbxUtil/api/Signal/) which is fired whenever an instance in the content provider\nqueue is being preloaded.",
            "lua_type": "Signal <instance: Instance>",
            "tags": [
                "Read only",
                "Signal",
                "ContentProviderQueue Instance"
            ],
            "source": {
                "line": 38,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "onInstanceAdded",
            "desc": " \n\nA [signal](https://sleitnick.github.io/RbxUtil/api/Signal/) which is fired whenever an instance is added to the content provider queue.",
            "lua_type": "Signal <instance: Instance>",
            "tags": [
                "Read only",
                "Signal",
                "ContentProviderQueue Instance"
            ],
            "source": {
                "line": 48,
                "path": "src/ContentProviderQueue/init.luau"
            }
        },
        {
            "name": "onInstanceRemoved",
            "desc": " \n\nA [signal](https://sleitnick.github.io/RbxUtil/api/Signal/) which is fired whenever an instance is removed from the content provider queue.",
            "lua_type": "Signal <instance: Instance>",
            "tags": [
                "Read only",
                "Signal",
                "ContentProviderQueue Instance"
            ],
            "source": {
                "line": 58,
                "path": "src/ContentProviderQueue/init.luau"
            }
        }
    ],
    "types": [
        {
            "name": "ContentProviderQueue",
            "desc": " ",
            "lua_type": "ContentProviderQueue",
            "source": {
                "line": 63,
                "path": "src/ContentProviderQueue/init.luau"
            }
        }
    ],
    "name": "ContentProviderQueue",
    "desc": " \n\nA simple class for working with [ContentProvider](https://create.roblox.com/docs/reference/engine/classes/ContentProvider).\n\n```lua\nlocal contentProviderQueue = ContentProviderQueue.new()\ncontentProviderQueue:addInstances({sound1, sound2, sound3})\nprint(#contentProviderQueue:pendingInstances()) --> 3\ncontentProviderQueue:fullyProgressed():await() -- ensure all pending instances are preloaded\nprint(#contentProviderQueue:pendingInstances()) --> 0\n```",
    "source": {
        "line": 14,
        "path": "src/ContentProviderQueue/init.luau"
    }
}