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: Using Proxies and Singletons... best practice question.  (Read 6653 times)
meekgeek
Full Member
***
Posts: 25


View Profile Email
« on: March 17, 2009, 05:44:21 »

I have an application I'm creating right now that requires me to use a Singleton that houses data related to the state of a view component.  The view component resides in my shell application, and I need to be able to have loaded modules affect the state of that view component.  I'll do this by having the Singleton dispatch events when data is changed.

I find it easier to do this because I ran into problems trying to do this with pipes (closing connections), and I'm not ready to jump into Fabrications just yet.  It's also a lot less code.

My question is - Is this the best way to do it?  and ( if this sounds like a good directiong ) What type of data object is that?

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



View Profile WWW Email
« Reply #1 on: March 18, 2009, 03:25:52 »

I'm noty really sure I can suggest a bets practice approach, since the model shouldn't really know about the view in MVC, particularly its state. Maybe you could describe a little about how you arrived at this design decision?

-=Cliff>
Logged
meekgeek
Full Member
***
Posts: 25


View Profile Email
« Reply #2 on: March 20, 2009, 11:42:40 »

Hey, Thanks for taking the time to respond, and sorry for not responding fast enough. 

The Model doesn't really know about the view in this case.  It just keeps certain boolean varialbes that switch on and off, and dispatches events when they are changed to anybody who has wants to listen.  For example, when I want certain elements to disable, I'll change a variable in the model. 

In reality, this is my answer to not using pipes, because for some reason, even after I 'removedCore' something remained in memory.  Causing the application to give me an error when I sent a message through pipe and then tried to grab an instance of it again next time I loaded my module.  ( Don't know if this is a bug ).

Anyway, I think Joshua Ostrom ran into the same thing and narrowed it down to having to close the 'Tsplit' connection.  But I don't think I can refactor the code at this stage.  The code is in his Mortgage App pipe demo http://www.joshuaostrom.com/2008/06/17/pipe-demo-mortgage-app/.

So that's where I'm at, and was hoping I could get some advice from the pros.  If you think this is a oop no no, I'll refactor next time to implements Joshua's techniques or use Fabrications?  Thanks again for responding to this.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: March 21, 2009, 12:14:17 »

If you really want to get the lowdown on how to manage memory when using modules have a look at Simon Bailey's excellent garbage collection article/demo. Its on his blog and I've linked to it under tutorials on the AS3 MultiCore menu.

I've used MultiCore and pipes in pretty demanding circumstances and I don't think the framework itself currently has any known bugs with regards to GC beyond the known GC problems in Flash Player versions prior to 10.

-=Cliff>
Logged
meekgeek
Full Member
***
Posts: 25


View Profile Email
« Reply #4 on: March 23, 2009, 09:32:51 »

Thanks Cliff, I'll make sure to take a look  ;D
Logged
meekgeek
Full Member
***
Posts: 25


View Profile Email
« Reply #5 on: March 27, 2009, 10:35:29 »

upon further exploring, I found that I was not properly removing my proxies in my dispose method.  This seems to have fixed my problems.
Logged
Pages: [1]
Print