P
P
Programep2016-09-02 22:16:20
JavaScript
Programep, 2016-09-02 22:16:20

What is the outline of the mediator template (observer) for the above code?

Good afternoon! I'm trying to rewrite my application according to patterns: modules, mediator, facade. Please tell me the beginning for the mediator in the code below. I understand that the call to player.draw_player(); should be in the mediator (or in the observer template?), but I can’t figure out how to write it better so that I don’t redo it less (at all) later.

var game_field = (function() {
     var field = {};
     return {
        draw_field: function() {
            /* code */
            player.draw_player();
            /* code */
        }
    }    
});
var player = (function(){
    var config = {};
    return {
        init_player: function(){},
        draw_player: function(){}
    }
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question