0

Suppose I have the following visual custom components:

2 Blocks: A & B

1 Link: C, connecting Block A & B

Now, if either Block A or B change, Link C has to be updated.

I am never sure how to handle this.

Do I :

a) pass both Block A & B to Line C so that it can add an event listener to each of them and act when a change happens.

b) pass Link C to both Block A & B so that when a Block changes it can notify the Link.

c) make the parent of both the Blocks and the Link responsible for updating all components.

I feel that this is a common problem, so I wonder if there is some sort of design pattern describing the best approach.

Any help would be appreciated.

4

1 回答 1

0

经过一番阅读,Mediator 模式似乎可以满足我的要求。

于 2013-07-18T15:35:36.470 回答