mediator

package
v0.0.0-...-7dcde51 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Example (One)
mediator := NewMediator()

jack := NewColleague("jack")
mediator.Register(jack)

tom := NewColleague("tom")
mediator.Register(tom)

bob := NewColleague("bob")
mediator.Register(bob)

jack.Speak("tom", "hi")
tom.Speak("bob", "hey")
Output:

tom: I heard "hi" from jack
bob: I heard "hey" from tom
Example (Two)
mediator := NewMediator()

jack := NewColleague("jack")
mediator.Register(jack)

tom := NewColleague("tom")
mediator.Register(tom)

bob := NewColleague("bob")
mediator.Register(bob)

jack.Speak("", "hi")
Output:

tom: I heard "hi" from jack
bob: I heard "hi" from jack

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Colleague

type Colleague interface {
	Name() string
	Speak(to, content string)
	OnListen(from, content string)
	SetMediator(mediator Mediator)
}

func NewColleague

func NewColleague(name string) Colleague

type Mediator

type Mediator interface {
	Whisper(from, to, content string)
	Register(colleague Colleague)
}

func NewMediator

func NewMediator() Mediator

Jump to

Keyboard shortcuts

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