notifications

package
v2.0.3+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2017 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dispatch

func Dispatch(q interface{})

Dispatch emits a event into the dispatch callback listeners.

func Subscribe

func Subscribe(dist EventDistributor)

Subscribe adds a new listener to the dispatcher.

func SubscribeWithRemover

func SubscribeWithRemover(dist EventDistributor) common.Remover

SubscribeWithRemover adds a new listener to the dispatcher and returns a common.Remover .

func Unsubscribe

func Unsubscribe(dist EventDistributor)

Unsubscribe adds a new listener to the dispatcher.

Types

type AppEvent

type AppEvent struct {
	UUID  string
	Event interface{}
}

AppEvent defines a struct to contain a event which occurs to be delivered to a giving AppNotification instance.

@notification:event

type AppEventHandler

type AppEventHandler struct {
	// contains filtered or unexported fields
}

AppEventHandler defines a structure type which implements the AppEventSubscriber interface and the EventDistributor interface.

func NewAppEventHandler

func NewAppEventHandler(fn func(AppEvent)) *AppEventHandler

NewAppEventHandler returns a new instance of a AppEventHandler.

func (*AppEventHandler) Handle

func (sn *AppEventHandler) Handle(receive interface{})

Handle takes the giving value and asserts the expected value to match the AppEvent type then passes it to the Receive method.

func (*AppEventHandler) Receive

func (sn *AppEventHandler) Receive(elem AppEvent)

Receive takes the giving value and execute it against the underline handler.

type AppEventNotification

type AppEventNotification struct {
	// contains filtered or unexported fields
}

AppEventNotification defines a structure type which must be used to receive AppEvent type has a event.

func AppNotification

func AppNotification(uid string) *AppEventNotification

AppNotification defines a structure which provides a local notification framework for the pubsub.

func NewAppEventNotification

func NewAppEventNotification() *AppEventNotification

NewAppEventNotification returns a new instance of NewAppEventNotification.

func NewAppEventNotificationWith

func NewAppEventNotificationWith(validation func(AppEvent) bool) *AppEventNotification

NewAppEventNotificationWith returns a new instance of AppEventNotification.

func (*AppEventNotification) Deliver

func (sn *AppEventNotification) Deliver(uuid string, item interface{})

Deliver delivers the giving value has a AppEvent.

func (*AppEventNotification) Handle

func (sn *AppEventNotification) Handle(elem interface{})

Handle takes the giving value and asserts the expected value to be of the type and pass on to it's underline subscribers else ignoring the event.

func (*AppEventNotification) Notify

func (sn *AppEventNotification) Notify(sub AppEventSubscriber)

Notify adds the given subscriber into the notification list and will await an update of a new event of the given AppEvent type.

func (*AppEventNotification) UnNotify

func (sn *AppEventNotification) UnNotify(sub AppEventSubscriber)

UnNotify removes the given subscriber from the notification's list if found from future events.

type AppEventSubscriber

type AppEventSubscriber interface {
	Receive(AppEvent)
}

AppEventSubscriber defines a interface that which is used to subscribe specifically for events AppEvent type.

type EventDistributor

type EventDistributor interface {
	Handle(interface{})
}

EventDistributor defines a interface that exposes a single method which will process a provided event received.

type Notifications

type Notifications struct {
	// contains filtered or unexported fields
}

Notifications defines a central delivery pipe where all types of event notifications will pass through to be delivered to all EventDistributor listening.

func New

func New() *Notifications

New returns a new instance of a Notification primitive.

func (*Notifications) Handle

func (n *Notifications) Handle(item interface{})

Handle will publish giving type to all internal EventDistributor who are expected to convert the needed interface{} into expected type for consumption for their internal state or operations.

func (*Notifications) Notify

func (n *Notifications) Notify(source EventDistributor)

Notify adds a giving EventDistributor into the notifications list.

func (*Notifications) UnNotify

func (n *Notifications) UnNotify(source EventDistributor)

UnNotify removes the giving distributor from the notification system.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL