Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Best to implement ViewStack or ViewStates or Both  (Read 5583 times)
kofiaddaquay
Full Member
***
Posts: 31


View Profile Email
« on: September 01, 2008, 07:42:49 »

Hi, i am building my first puremvc project and i have tons of questions  :o ... just so i can keep everything short...my question is this..

in my application so far, the only way i am changing states is with the viewstack...but all of a sudden i am having the urge to have different viewstates within my components and changing the currentState instead of just creating a new component as the new state. creating a new component might be longer...but i really dont care. i just want to make sure i am building it with the right architecture. Can you please comment on which might be best. am i better off  using a viewstack?? rather than mixing viewstacks and viewstates ?
Logged
danielcsgomes
Full Member
***
Posts: 47

 - daniel@onedesign.com.pt
View Profile Email
« Reply #1 on: September 01, 2008, 11:52:54 »

Hi,

I can tell you my personal experience, i am currently building my first real project with PureMVC and in my frontend i use the viewstack to change the contents but it will be like a website. But in the Backend i use the viewstack only for change the login panel to the main application, then i load/unload my modules when i need. But some modules can have some viewstacks always depends on contents ;)

ViewStacks have a "little" problem in PureMVC, Deferred Instatiacion, but Cliff already resolved it and make a demo "Slacker Demo" it explains how to handle with Deferred Instatiacion.

Daniel Gomes
Logged
kofiaddaquay
Full Member
***
Posts: 31


View Profile Email
« Reply #2 on: September 02, 2008, 12:14:42 »

Thanks for your feedback Daniel. Can you explain what you mean by "like a website"? you mean moving from one view to another in the viewstack? You could always control that will transitions cant you?.. to smoothing things out :). ALSO..i didnt understand this statment

"But some modules can have some viewstacks always depends on contents" ? what do you mean

I will take a look at the Slacker Demo, but i still need to know if i can mix the 2.  for example...in my login form(username and password fields), there is an option to register. i was going to create a new state called register so when you clicks on the register link the view state will change to register state. because most of the sample demo on puremvc use viewstack for navigation..i created a new register component / form (with username, password, firstname etc etc field ). i found this to be a bit tedious having to create a register mediator and proxy etc ! instead of having that as part of login mediator etc.(its the same component with dif state) i hope what i am saying is clear :'(

again like i said..if thats the best practice(to create a new component) and not use view states, the i dont care i will do to it. i just need to know what my options are  :-\

Thanks
Kofi
Logged
danielcsgomes
Full Member
***
Posts: 47

 - daniel@onedesign.com.pt
View Profile Email
« Reply #3 on: September 02, 2008, 12:30:53 »

Well a website can be "simpler" or "complex" but what i tried said was when you got some buttons and a main "container" that will have the contents for the buttons in this case i use a viewstack.

About the second question, imagine that:

A Module that have the recently news and the most view news, in this case i will use a view stack but you can load it to your application and put it on a side bar or other place you don't have to put this module in a view stack, my english is not good and sometimes is hard to me to explain, do you understood what i am trying say?

Off course you can mix, you should think in your projects on a simple way, try to make separated modules that can be reuse in other projects and can be totally independent of other Modules. ;) Sometimes you will have one, two,three viewstacks inside a module others maybe you will not use it, like i said it always depends on project ;)

Sorry my english ;)

Daniel Gomes
Logged
kofiaddaquay
Full Member
***
Posts: 31


View Profile Email
« Reply #4 on: September 02, 2008, 09:42:44 »

i think i get what you mean..

is there any sample on this site that uses viewstates instead of view stacks? or do you know any?
Logged
danielcsgomes
Full Member
***
Posts: 47

 - daniel@onedesign.com.pt
View Profile Email
« Reply #5 on: September 03, 2008, 12:07:50 »

I already made one demo but just use one viewstack to change from login to the main application, in main application it add 3 components and handle with deferred instatiation. You can see it here:

http://forums.puremvc.org/index.php?topic=639.0

But i think doesn't exists any demo with more then one viewstack.

Daniel Gomes
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #6 on: September 04, 2008, 01:13:50 »

View states present a minor challenge similar to what view stacks do in that some children may not be available.

With viewstacks, this is just at the start when only the first child may be available. 'Slacker' is focused on how to spawn mediators for the other chldren once they do become available.

However in a component with Flex view states, you may transition from state to state at runtime, and might not need extra mediators for the children that are added and removed. If you do, it is a tougher problem than the viewstack because you need to register and remove mediators as you move between states. 
The more likely scenario is one mediator for the component and then the problem is only the event listeners. The mediator will want to place them on the component and the transient children send bubbling events. The mediator may query the currentState property if it needs to interpret an event based on the state, but if all the props that it reads are defined in a script block in the component, it really doesn't need to care about the component's state.

-=Cliff>
Logged
Pages: [1]
Print