package subscribers

import (
	"quyun/providers/event"

	"go.ipao.vip/atom"
	"go.ipao.vip/atom/container"
	"go.ipao.vip/atom/contracts"
	"go.ipao.vip/atom/opt"
)

func Provide(opts ...opt.Option) error {
	if err := container.Container.Provide(func(
		__event *event.PubSub,
	) (contracts.Initial, error) {
		obj := &UserRegister{}
		if err := obj.Prepare(); err != nil {
			return nil, err
		}
		__event.Handle("handler:UserRegister", obj.Topic(), obj.PublishToTopic(), obj.Handler)

		return obj, nil
	}, atom.GroupInitial); err != nil {
		return err
	}
	return nil
}
