Show raw api
{
"functions": [
{
"name": "new",
"desc": "Constructs a new ServiceBag",
"params": [
{
"name": "parentProvider",
"desc": "Optional parent provider to find services in",
"lua_type": "ServiceBag?"
}
],
"returns": [
{
"desc": "",
"lua_type": "ServiceBag"
}
],
"function_type": "static",
"source": {
"line": 59,
"path": "src/servicebag/src/Shared/ServiceBag.lua"
}
},
{
"name": "isServiceBag",
"desc": "Returns whether the value is a serviceBag",
"params": [
{
"name": "value",
"desc": "",
"lua_type": "ServiceBag?"
}
],
"returns": [
{
"desc": "",
"lua_type": "boolean"
}
],
"function_type": "static",
"source": {
"line": 86,
"path": "src/servicebag/src/Shared/ServiceBag.lua"
}
},
{
"name": "GetService",
"desc": "Retrieves the service, ensuring initialization if we are in\nthe initialization phase.",
"params": [
{
"name": "serviceType",
"desc": "",
"lua_type": "ServiceType"
}
],
"returns": [
{
"desc": "",
"lua_type": "any"
}
],
"function_type": "method",
"source": {
"line": 103,
"path": "src/servicebag/src/Shared/ServiceBag.lua"
}
},
{
"name": "HasService",
"desc": "Returns whether the service bag has the service.",
"params": [
{
"name": "serviceType",
"desc": "",
"lua_type": "ServiceType"
}
],
"returns": [
{
"desc": "",
"lua_type": "boolean"
}
],
"function_type": "method",
"source": {
"line": 133,
"path": "src/servicebag/src/Shared/ServiceBag.lua"
}
},
{
"name": "Init",
"desc": "Initializes the service bag and ensures recursive initialization\ncan occur",
"params": [],
"returns": [],
"function_type": "method",
"source": {
"line": 149,
"path": "src/servicebag/src/Shared/ServiceBag.lua"
}
},
{
"name": "Start",
"desc": "Starts the service bag and all services",
"params": [],
"returns": [],
"function_type": "method",
"source": {
"line": 167,
"path": "src/servicebag/src/Shared/ServiceBag.lua"
}
},
{
"name": "IsStarted",
"desc": "Returns whether the service bag has fully started or not.",
"params": [],
"returns": [
{
"desc": "",
"lua_type": "boolean"
}
],
"function_type": "method",
"source": {
"line": 216,
"path": "src/servicebag/src/Shared/ServiceBag.lua"
}
},
{
"name": "CreateScope",
"desc": "Creates a scoped service bag, where services within the scope will not\nbe accessible outside of the scope.",
"params": [],
"returns": [
{
"desc": "",
"lua_type": "ServiceBag"
}
],
"function_type": "method",
"source": {
"line": 226,
"path": "src/servicebag/src/Shared/ServiceBag.lua"
}
},
{
"name": "Destroy",
"desc": "Cleans up the service bag and all services that have been\ninitialized in the service bag.",
"params": [],
"returns": [],
"function_type": "method",
"source": {
"line": 322,
"path": "src/servicebag/src/Shared/ServiceBag.lua"
}
}
],
"properties": [],
"types": [
{
"name": "Service",
"desc": "",
"fields": [
{
"name": "Init:",
"lua_type": "function?",
"desc": ""
},
{
"name": "Start:",
"lua_type": "function?",
"desc": ""
},
{
"name": "Destroy:",
"lua_type": "function?",
"desc": ""
}
],
"source": {
"line": 43,
"path": "src/servicebag/src/Shared/ServiceBag.lua"
}
},
{
"name": "ServiceType",
"desc": "",
"lua_type": "Service | ModuleScript",
"source": {
"line": 48,
"path": "src/servicebag/src/Shared/ServiceBag.lua"
}
}
],
"name": "ServiceBag",
"desc": "Service bags handle recursive initialization of services, and the\nretrieval of services from a given source. This allows the composition\nof services without the initialization of those services becoming a pain,\nwhich makes refactoring downstream services very easy.\n\nThis also allows multiple copies of a service to exist at once, although\nmany services right now are not designed for this.\n\n```lua\nlocal serviceBag = ServiceBag.new()\n\nserviceBag:GetService({\n\tInit = function(self)\n\t\tprint(\"Service initialized\")\n\tend;\n})\nserviceBag:Init()\nserviceBag:Start()\n```\n\n:::tip\nServiceBag does not allow services to yield on :Init() or :Start(), nor\ndoes it allow you to add services after :Init() or :Start()\n:::",
"source": {
"line": 29,
"path": "src/servicebag/src/Shared/ServiceBag.lua"
}
}