Skip to content

intervinn/wirebox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wirebox

Pesde

The Luau Dependency Injection container based on constructors.

Features

  • Designed to work with typical modular roblox codebases
  • Extensible and simple, inspired by .NET standard DI

Install

With pesde:

$ pesde add intervinn/wirebox
$ pesde install

Usage

The /test directory also covers each feature.

local Wirebox = require("../lib")
local Provider = Wirebox.Provider
local Collection = Wirebox.Collection

local c = Collection.new()
local provide = Wirebox.provide(c)

local Logger = {}
Logger.__index = Logger
function Logger.new()
    return setmetatable({}, Logger)
end
function Logger:log(msg)
    print(msg)
end

local App = {}
App.__index = App
function App.new(logger)
    return setmetatable({
        Logger = logger
    }, App)
end
function App:start()
    self.Logger:log("hello world")
end


provide(Logger.new):Singleton():Name("Logger")
provide(App.new):With(Logger.new):Singleton():Name("App")

local p = Provider.FromCollection(c)
local app = p:GetService(App.new)
app:start()

Contributing

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.

License

This project is licensed under the MIT license.

About

Constructor-based Dependency Injection for Luau

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages