js设计模式之BehavioralPatterns之Mediator
程序员文章站
2022-11-15 21:20:57
js设计模式之behavioralpatterns之mediator。
in this example we’ll greatly simplify the co...
js设计模式之behavioralpatterns之mediator。
in this example we’ll greatly simplify the communication between the houses and
say that all messages pass through the great lord. in this case we’ll use the house of
stark as our great lord. they have a number of other houses which talk with them.
class karstark { constructor(greatedlord){ this.greatlord = greatedlord; } receivemessage(message){ } sendmessage(message){ this.greatlord.routemessage(message); } }
they have two functions, one of which receives messages from a third party and one
of which sends messages out to their great lord, which is set upon instantiation
class housestark{ constructor(){ this.karstark = new karstark(this); this.bolton = new bolton(this); this.frey = new frey(this); this.umber = new umber(this); } routemessage(message) { } }
下一篇: 奶粉排行榜10强,大家一起去了解了解