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
Properties
onInstancePreloaded
Read onlySignalContentProviderQueue InstanceContentProviderQueue.onInstancePreloaded:
Signal
<
instance:
Instance,
contentProviderId:
string,
deltaTime:
number,
status:
Enum.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 InstanceA signal which is fired whenever an instance in the content provider queue is being preloaded.
onInstanceAdded
Read onlySignalContentProviderQueue InstanceA signal which is fired whenever an instance is added to the content provider queue.
onInstanceRemoved
Read onlySignalContentProviderQueue InstanceA signal which is fired whenever an instance is removed from the content provider queue.
Functions
new
Creates a new content preloader queue. An initialUpdateInterval
argument can be passed
as the initial update interval of the queue.
is
ContentProviderQueue.
is
(
self:
any
) →
boolean
Returns a boolean indicating whether or not self
is a ContentProviderQueue object or not.
setUpdateInterval
ContentProviderQueue:
setUpdateInterval
(
updateInterval:
number
) →
(
)
Sets the update interval of the queue, i.e the interval at which the queue will preload each asset.
add
Adds the given instance to the content provider queue. If the given instance already exists, then the instance will not be readded again.
addInstances
Adds all instances in instances
to the content provider queue, via ContentProviderQueue:add.
remove
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
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.