mpdp

package
v0.0.0-...-3faa710 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package mpdp observer User: 姜伟 Time: 2020-02-19 06:27:16

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IObserver

type IObserver interface {
	Notify(data interface{})
}

IObserver 观察者接口

type ISubject

type ISubject interface {
	AddObservers(observers ...IObserver)    // 添加观察者
	ClearObservers()                        // 清空观察者
	NotifyObservers(data interface{}) error // 通知观察者
}

ISubject 被观察者接口

type SubjectBasic

type SubjectBasic struct {
	Observers []IObserver
}

SubjectBasic 被观察者基础结构体

func NewSubject

func NewSubject() SubjectBasic

NewSubject 实例化被观察者

func (*SubjectBasic) AddObservers

func (subject *SubjectBasic) AddObservers(observers ...IObserver)

AddObservers 添加观察者

func (*SubjectBasic) ClearObservers

func (subject *SubjectBasic) ClearObservers()

ClearObservers 清空观察者

Jump to

Keyboard shortcuts

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