BindableOrderedCallback

Occasionally I will want to do something like this

-- some code doAndWaitForA() doAndWaitForB() doAndWaitForC() -- other code

My solution is usually something like this, because I want it to be easily scalable and modular

[code]local bound = {}
script.Bind.OnInvoke = function(callback)
table.insert(bound, callback)
end

– some code
for i, func in next, bound do func() end
– other code[/code]

But this is annoying. I want native support for it.

Class BindableOrderedCallback : Instance Function void BindCallback(string name, number priority, function callback) Function void UnbindCallback(string name) Function bool IsCallbackBound(string name) Function void Invoke(Tuple arguments)

You would use BindCallback to bind a callback that will be called and waited for. Invoke will call the callbacks one-at-a-time in order from lowest priority to highest (and pass the arguments used on Invoke).

This has a different use than a BindableEvent because I want to yield until all of the bound functions finish running. This has a different use than a BindableFunction because I want to bind an arbitrary number of functions.