// NOTE this is a generated file! do not edit!

package channel_points_community_goal

import (
	"context"

	"github.com/golang/protobuf/proto"

	eventbus "code.justin.tv/eventbus/client"
)

const (
	UpdateEventType = "ChannelPointsCommunityGoalUpdate"
)

type Update = ChannelPointsCommunityGoalUpdate

type ChannelPointsCommunityGoalUpdateHandler func(context.Context, *eventbus.Header, *ChannelPointsCommunityGoalUpdate) error

func (h ChannelPointsCommunityGoalUpdateHandler) Handler() eventbus.Handler {
	return func(ctx context.Context, message eventbus.RawMessage) error {
		dst := &ChannelPointsCommunityGoalUpdate{}
		err := proto.Unmarshal(message.Payload, dst)
		if err != nil {
			return err
		}
		return h(ctx, message.Header, dst)
	}
}

func RegisterChannelPointsCommunityGoalUpdateHandler(mux *eventbus.Mux, f ChannelPointsCommunityGoalUpdateHandler) {
	mux.RegisterHandler(UpdateEventType, f.Handler())
}

func RegisterUpdateHandler(mux *eventbus.Mux, f ChannelPointsCommunityGoalUpdateHandler) {
	RegisterChannelPointsCommunityGoalUpdateHandler(mux, f)
}

func (*ChannelPointsCommunityGoalUpdate) EventBusName() string {
	return UpdateEventType
}
