example

package
v0.0.0-...-05962f3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Colleague

type Colleague interface {
	SetMediator(mediator Mediator)
}

同事类接口

type ConcreteColleague1

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

具体同事1

func (*ConcreteColleague1) Respond

func (b *ConcreteColleague1) Respond()

执行动作

func (*ConcreteColleague1) SetMediator

func (b *ConcreteColleague1) SetMediator(mediator Mediator)

设置中介

type ConcreteColleague2

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

具体同事2

func (*ConcreteColleague2) Respond

func (t *ConcreteColleague2) Respond()

执行动作

func (*ConcreteColleague2) SetMediator

func (t *ConcreteColleague2) SetMediator(mediator Mediator)

设置中介

func (*ConcreteColleague2) Talk

func (t *ConcreteColleague2) Talk()

通过中介者谈话

type ConcreteMediator

type ConcreteMediator struct {
	ConcreteColleague1
	ConcreteColleague2
}

ConcreateMediator 描述了 ConcreteColleague1 和 ConcreteColleague2 之间的中介

func NewMediator

func NewMediator() *ConcreteMediator

NewMediator 创建一个具体中介者 ConcreateMediator

func (*ConcreteMediator) Communicate

func (m *ConcreteMediator) Communicate(who string)

Communicate 在 ConcreteColleague1 和 ConcreteColleague2 之间进行通信

type Mediator

type Mediator interface {
	Communicate(who string)
}

Mediator 描述了具体同事之间通信的接口

Jump to

Keyboard shortcuts

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