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

kittizz/fxx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🦜 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{}
}