The Luau Dependency Injection container based on constructors.
- Designed to work with typical modular roblox codebases
- Extensible and simple, inspired by .NET standard DI
With pesde:
$ pesde add intervinn/wirebox
$ pesde installThe /test directory also covers each feature.
localWirebox=require("../lib")
localProvider=Wirebox.ProviderlocalCollection=Wirebox.Collectionlocalc=Collection.new()
localprovide=Wirebox.provide(c)
localLogger= {}
Logger.__index=LoggerfunctionLogger.new()
returnsetmetatable({}, Logger)
endfunctionLogger:log(msg)
print(msg)
endlocalApp= {}
App.__index=AppfunctionApp.new(logger)
returnsetmetatable({
Logger=logger
}, App)
endfunctionApp:start()
self.Logger:log("hello world")
endprovide(Logger.new):Singleton():Name("Logger")
provide(App.new):With(Logger.new):Singleton():Name("App")
localp=Provider.FromCollection(c)
localapp=p:GetService(App.new)
app:start()Contributions are heavily welcomed! There are no contributions guide currently. If you have an idea to improve the project, open the issue before working on PR.
This project is licensed under the MIT license.