Y
Y
Yuri Kulyash2012-11-22 20:23:07
JavaScript
Yuri Kulyash, 2012-11-22 20:23:07

Call chain in object dependency tree

Suggest a pattern or algorithm for the following task: there are a number of objects that are logically connected to each other in the likeness of a tree. With a certain change in one of them, a parent method may be called, which in turn may also change and call a method from its parent (or may not call a test by condition). This happens along the chain of relationships in the tree. Also, the call can come from parents, while branching is possible (calling several methods from different objects). There should be no cycles (they are not in the interconnection logic): that is, the call goes in one direction and cannot return to the original one. The division into parents and descendants is conditional for this task, there is no inheritance. Preferably OOP. With JS, I'm at a beginner level.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Konstantin Kitmanov, 2012-11-22
@k12th

It seems that you need a pattern that is either Observer or PubSub.

K
Kirill, 2012-11-22
@kirill89

It seems to me that chain of responsibility solves a similar problem.

D
Denis Pushkarev, 2012-11-22
@rock

Observer , or, as its kind, an event emitter with bubbling and capturing events, like in dom?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question