InsertService:LoadAsset() is a yielding function as stated in the wiki (probably the same applies to require(ModuleID)) and DataStore requests are also yielding functions. Is it a good practice to use these functions in a pcall? I’ve only seen such practice done using DataStores but not require() and :LoadAsset()
Edit:
An example of what I’m talking about
local Module
pcall(function()
Module = require(ModuleID)
end)
local Asset
pcall(function()
Asset = InsertService:LoadAsset(AsssetID)
end)
i barly use loadasset. but for a yielding pcall in roblox i’d use a ypcall. as its stated to be the yielding version of pcall. require can be used by e.g. also datastores. your main datastore code goes in the module (as i use Object Orientated Programming. aka OOP for it) and you basically call all its functions of the module to your script.
edit
this is all the script does. everything important is done in the module script. even the (y)pcall for data
Yeah, it’s a good practice. Those could fail due to connectivity or database errors that are beyond your control, and you’ll need to handle them if you want your code to be robust.
i did not know that, i remember reading that ypcall is basically the yielding version of pcall. i guess ypcall is excessive to use since it is a thing which isn’t documented on the wiki for some reason. is there really any reason to not depricate ypcall?
Since it isn’t even documented in the wiki (anymore, at least), something tells me that it’s all but deprecated. It makes sense to still keep it around, though, since you might import libraries that aren’t written specifically for Roblox and those libraries might be using ypcall.
(Also I think it’s a bit weird to deprecate stuff that were in vanilla Lua. It would definitely be a first!)
EDIT: Okay on second thought this wouldn’t be a first. string.dump is useless in Roblox because it’s effectively been disabled to prevent exploits. The point still stands, though.