سؤال

I'm currently using RobotLegs with the Presentation Model pattern to develop a Flex 4 project. I understand that all business logic related to a View resides in the Presentation Model associated with that view, however, I am confused when it comes to View specific logic.

For example, I have an indicator that needs to be positioned relatively to list items depending on which list item is selected. Is it acceptable in the Presentation pattern to put the logic that will position the indicator in the View and simply have that logic run in reaction to a selectedIndex property changing in the presentation model?

The reason I am considering this is that since the Presentation Model does not have a reference to the view it is difficult to come up with an ideal solution for manipulating view components.

هل كانت مفيدة؟

المحلول

Ask yourself this: if you had to use the same Presentation Model with a view that looked different (for instance, a mobile View), would you still need to handle this, and could you abstract it enough to handle it the same way from the PM?

It sounds to me like you're moving the indicator relative to the itemRenderer, which suggests that you may want to have some sort of reference to the renderer or its coordinates in the PM (var indicatorIsRelativeTo:InteractiveObject or var indicatorIsRelativeTo:Rect). You may even want to have another variable that describes how it is relative to that object (above, below, left, right).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top