flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mark goldin <markzolo...@gmail.com>
Subject Re: Binding and singleton
Date Fri, 14 Nov 2014 17:46:29 GMT
Yes, it does bring external content and it is a module. But how come then
other modules are getting same models after they are unloaded and loaded
again?

On Fri, Nov 14, 2014 at 11:42 AM, Alex Harui <aharui@adobe.com> wrote:

> OK, so as we all expect, it works as expected in most cases.  So, what is
> different about this particular model?  I noticed you used the work “load
> it again”.  “Load" to me means bringing in external content.  If this
> Singleton is in a module or sub-app that gets unloaded and reloaded, then
> yes, it will get a new instance each time.
>
> On 11/14/14, 2:16 AM, "mark goldin" <markzolotoy@gmail.com> wrote:
>
> >I just ran in the way you did. In the same mxml it does show same object
> >id, but once I leave the screen and load it again I am getting a new
> >object
> >id.
> >
> >On Fri, Nov 14, 2014 at 4:07 AM, mark goldin <markzolotoy@gmail.com>
> >wrote:
> >
> >> Yes, I understand what you are saying. I have several models. They all
> >> behave correctly and this one only creates a new instance every time.
> >> I have changed my code to look like other models:
> >> package
> >> {
> >> import com.adobe.cairngorm.model.IModelLocator;
> >> import flash.events.EventDispatcher;
> >>  [Bindable]
> >> public class ModelLocator extends EventDispatcher implements
> >>IModelLocator
> >> {
> >> private static var _instance:ModelLocator;
> >>
> >> public function ModelLocator(enforcer:SingletonEnforcer)
> >> {
> >> if (enforcer == null){
> >> throw new Error("You can have only one ModelLocator");
> >> }
> >> }
> >>  public static function getInstance():ModelLocator{
> >>  if (_instance == null){
> >> _instance = new ModelLocator(new SingletonEnforcer());
> >>  }
> >>  return _instance;
> >>  }
> >> }
> >> }
> >> class SingletonEnforcer{}
> >>
> >>
> >> On Fri, Nov 14, 2014 at 3:12 AM, Krüger, Olaf <OKrueger@edscha.com>
> >>wrote:
> >>
> >>> >When I am debugging I see that _instance is always different object
> >>>when
> >>> I get an instance of my singleton. Is that right?
> >>>
> >>> I don't know if this is helpful:
> >>> I've tested your singleton implementation by creating some instances of
> >>> 'ModelLocator'.
> >>> As expected it always returns the same instance of 'ModelLocator' with
> >>> the same "object id" (@9760161)'.
> >>> So if you have a different behaviour you should do some research to
> >>>make
> >>> sure your singleton works as expected.
> >>>
> >>> <fx:Script>
> >>> <![CDATA[
> >>> private var modelLocator1:ModelLocator;
> >>> private var modelLocator2:ModelLocator;
> >>> private var modelLocator3:ModelLocator;
> >>> private var modelLocator4:ModelLocator;
> >>>
> >>> public function init():void{
> >>>         modelLocator1 = ModelLocator.getInstance();  // ModelLocator
> >>> (@9760161)
> >>>         modelLocator2 = ModelLocator.getInstance();  // ModelLocator
> >>> (@9760161)
> >>>         modelLocator3 = ModelLocator.getInstance();  // ModelLocator
> >>> (@9760161)
> >>>         modelLocator4 = ModelLocator.getInstance();  // ModelLocator
> >>> (@9760161)
> >>> }
> >>> ]]>
> >>> </fx:Script>
> >>>
> >>> Olaf
> >>>
> >>>
> >>> ________________________________
> >>>
> >>> Edscha Holding GmbH
> >>> Sitz der Gesellschaft: Remscheid
> >>> Registergericht: Wuppertal, HRB 22889
> >>> Geschäftsführung: Francisco J. Riberas Mera, Francisco López Peña,
> >>>David
> >>> Vázquez Pascual, Torsten Greiner, Markus Kirchner, Hans-Peter Schulz
> >>>und
> >>> Volker Weiss
> >>>
> >>> Vertretungsberechtigt sind nur Geschäftsführer und schriftlich
> >>> Bevollmächtigte.
> >>>
> >>> Solely Managing Directors or employees with a written proxy have got
> >>> power of representation.
> >>>
> >>> Der Inhalt dieser E-Mail einschließlich etwaiger beigefügter Dateien
> >>>ist
> >>> vertraulich und nur für den Empfänger bestimmt. Sollten Sie nicht der
> >>> bestimmungsgemäße Empfänger sein, ist Ihnen jegliche Offenlegung,
> >>> Vervielfältigung, Weitergabe oder Nutzung des Inhalts untersagt. Bitte
> >>> informieren Sie in diesem Fall unverzüglich den Absender und löschen
> >>>Sie
> >>> die E-Mail einschließlich etwaiger beigefügter Dateien von Ihrem
> >>>System.
> >>> Vielen Dank.
> >>>
> >>> The contents of this e-mail including any attachments are confidential
> >>> and may be legally privileged. If you are not the intended recipient,
> >>>any
> >>> disclosure, copying, distribution or use of its contents is strictly
> >>> prohibited, and you should please notify the sender immediately and
> >>>then
> >>> delete this e-mail including any attachments from your system. Thank
> >>>you.
> >>>
> >>
> >>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message