observer

package
Version: v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 3 Imported by: 125

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultObserver = Observer{
	NextHandler: func(interface{}) {},
	ErrHandler:  func(err error) {},
	DoneHandler: func() {},
}

DefaultObserver guarantees any handler won't be nil.

Functions

This section is empty.

Types

type Observer

type Observer struct {
	NextHandler handlers.NextFunc
	ErrHandler  handlers.ErrFunc
	DoneHandler handlers.DoneFunc
}

Observer represents a group of EventHandlers.

func New

func New(eventHandlers ...rx.EventHandler) Observer

New constructs a new Observer instance with default Observer and accept any number of EventHandler

func (Observer) Handle

func (ob Observer) Handle(item interface{})

Handle registers Observer to EventHandler.

func (Observer) OnDone

func (ob Observer) OnDone()

OnDone terminates the Observer's internal Observable

func (Observer) OnError

func (ob Observer) OnError(err error)

OnError applies Observer's ErrHandler to an error

func (Observer) OnNext

func (ob Observer) OnNext(item interface{})

OnNext applies Observer's NextHandler to an Item

type ObserverMock

type ObserverMock struct {
	mock.Mock
}

func NewObserverMock

func NewObserverMock() *ObserverMock

func (*ObserverMock) Capture

func (m *ObserverMock) Capture() Observer

func (*ObserverMock) OnDone

func (m *ObserverMock) OnDone()

OnDone provides a mock function with given fields:

func (*ObserverMock) OnError

func (m *ObserverMock) OnError(err error)

OnError provides a mock function with given fields: err

func (*ObserverMock) OnNext

func (m *ObserverMock) OnNext(item interface{})

OnNext provides a mock function with given fields: item

Jump to

Keyboard shortcuts

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