当前位置: 移动技术网 > IT编程>开发语言>JavaScript > js设计模式之BehavioralPatterns之Mediator

js设计模式之BehavioralPatterns之Mediator

2019年05月06日  | 移动技术网IT编程  | 我要评论

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) {

    }
}

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网