javascript - How to handle this cycle dependency? -


i have design this:

  1. ui layer
  2. component layer.

the idea event handlers click, painting dom hitting ui layer, call corresponding component layer.

now imagine on click of button, ui layer calls component layer, dependencies looks this:

define(['creationcomponent']) //ui layer module 

so on click of button, module can call creationcomponent methods.

now creationcomponent too, in order paint something, calls ui layer, creationcomponent looks this:

define(['uilayer']) //create module 

and here go dependencies cycle, i'm making mistake in design process?

i not think ui layer should call component layer if event happened. should send event. use observer pattern here. after sent event, should not care if handled or not.

when component needs draw itself, guess here actual call should happen since action can not forgotten , handling cannot skipped.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -