Skip to content
This repository has been archived by the owner. It is now read-only.

Latest commit

 

History

History
62 lines (45 loc) · 1.09 KB

README.md

File metadata and controls

62 lines (45 loc) · 1.09 KB

🦜 Fxx GoDoc

An add on for Fx:

  • add func MultiProvide() fx.Option.

Installation

We recommend locking to SemVer range ^1 using go mod:

go get go.uber.org/fx@v1
go get github.com/kittizz/fxx

Example

func main() {
	fx.New(
		fxx.MultiProvide(
			repository.NewRepository,
			user_service.NewUserService,
		),
		fx.Invoke(
			func(
				userRepo *user_repository.UserRepository,
				orderRepo *order_repository.OrderRepository,
			) {
				fmt.Println("Loadin :", userRepo.GetUser())
				for k, v := range orderRepo.List() {
					fmt.Println("My Order >", "["+k+"]", v)
				}
				os.Exit(0)
			},
		),
	).Run()
}
....

package repository

var NewRepository = fxx.Modules(
	user_repository.NewUserRepository,
	order_repository.NewOrderRepository,
)
....

package user_service

func NewUserService() *UserService {
	return &UserService{}
}