javascript - How to handle this cycle dependency? -
i have design this:
- ui layer
- 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
Post a Comment