observable

package
v4.8.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	// Subject identifies what changed.
	// By convention, it corresponds to the corresponding GET endpoint of the REST API.
	Subject string `json:"subject"`

	// Action describes how the change has to be applied.
	Action action.Action `json:"action"`

	// Object contains the data that changed.
	Object interface{} `json:"object"`
}

Event is passed to the listeners of an observable type.

type Implementation

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

Implementation can be embedded in implementations that are observable.

func (*Implementation) Notify

func (implementation *Implementation) Notify(event Event)

Notify notifies the registered observers about the given event. This method should only be called from the implementation itself.

func (*Implementation) Observe

func (implementation *Implementation) Observe(observer func(Event)) func()

Observe implements observable.Observe.

type Interface

type Interface interface {
	// Observe registers the given callback and returns a function to unobserve again.
	Observe(func(Event)) func()
}

Interface can be embedded in interfaces that are observable.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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