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 Thu, 13 Nov 2014 21:17:21 GMT
Agree about details. But do not with overlapping.
Your label does not show its text. Can you imagine how many problems that
can be caused by? But here we are talking about singletons and binding, a
bit more complicated, at least for me.

On Thu, Nov 13, 2014 at 3:12 PM, OmPrakash Muppirala <bigosmallm@gmail.com>
wrote:

> On Thu, Nov 13, 2014 at 1:09 PM, mark goldin <markzolotoy@gmail.com>
> wrote:
>
> > I am very sorry for the confusion. I do have it in exactly same way. I
> was
> > trying not to provide too much details. What can I say ...
> >
> >
> You should always try to provide as much detail as possible when asking a
> question.  Also, please try not to create multiple threads at the same time
> talking about overlapping issues.
>
> Thanks,
> Om
>
>
> > On Thu, Nov 13, 2014 at 3:04 PM, Alex Harui <aharui@adobe.com> wrote:
> >
> > > In this example, the ‘data’ property is an Object.  Properties assigned
> > to
> > > Objects are not bindable.  There should have been warnings in the
> compile
> > > output or in the console at runtime.
> > >
> > > If you know the set of properties on the data object, you should
> define a
> > > class for that.
> > >
> > > [Bindable]
> > > public class MyModelDataSubObject
> > > {
> > >    public var propOnData:String;
> > > }
> > >
> > > And:
> > >
> > > [Bindable]
> > > public class ModelLocator extends EventDispatcher implements
> > IModelLocator
> > > {
> > > private static var _instance:ModelLocator;
> > > public var data:MyModelDataSubObject;
> > > public function ModelLocator(enforcer:SingletonEnforcer)
> > > ..
> > >
> > >
> > > -Alex
> > >
> > > On 11/13/14, 12:49 PM, "mark goldin" <markzolotoy@gmail.com> wrote:
> > >
> > > >Something like this. A bit simplified:
> > > >package
> > > >{
> > > >
> > > >[Bindable]
> > > >public class ModelLocator extends EventDispatcher implements
> > IModelLocator
> > > >{
> > > >private static var _instance:ModelLocator;
> > > >public var data:Object;
> > > > 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 Thu, Nov 13, 2014 at 2:44 PM, Alex Harui <aharui@adobe.com> wrote:
> > > >
> > > >> Declaring a class [Bindable] does not make its sub-objects bindable.
> > > >>Show
> > > >> us the code for the model’s data property.
> > > >>
> > > >> -Alex
> > > >>
> > > >> On 11/13/14, 12:31 PM, "mark goldin" <markzolotoy@gmail.com>
wrote:
> > > >>
> > > >> >It's an object. The whole model class is Bindable.
> > > >> >
> > > >> >On Thu, Nov 13, 2014 at 2:11 PM, Alex Harui <aharui@adobe.com>
> > wrote:
> > > >> >
> > > >> >> It appears you are binding to sub-objects in the model, and
they
> > may
> > > >>not
> > > >> >> be bindable.  What is _model.data?
> > > >> >>
> > > >> >> -Alex
> > > >> >>
> > > >> >> On 11/13/14, 10:49 AM, "mark goldin" <markzolotoy@gmail.com>
> > wrote:
> > > >> >>
> > > >> >> >No, they are not static. I even replaces public var ...
with
> > setter
> > > >>and
> > > >> >> >getter. Still the same.
> > > >> >> >Here more code for singleton:
> > > >> >> >public var data:Object;
> > > >> >> >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{}
> > > >> >> >
> > > >> >> >
> > > >> >> >In another class I am getting an instance of singleton:
> > > >> >> >private var _model:ModelLocator = ModelLocator.getInstance();
> > > >> >> >
> > > >> >> >BindingUtils.bindSetter(onDataLoaded, _Model.data,
> "propOnData");
> > > >> >> >new GetDataEvent().dispatch();
> > > >> >> >
> > > >> >> >public function onDataLoaded(value:String):void
> > > >> >> >{
> > > >> >> >trace(2);
> > > >> >> >if (value)
> > > >> >> >{
> > > >> >> >......
> > > >> >> >}
> > > >> >> >}
> > > >> >> >
> > > >> >> >this is a command that set to get data when GetDataEvent
event
> is
> > > >> >> >triggered:
> > > >> >> >
> > > >> >> >public function result(data:Object):void
> > > >> >> >{
> > > >> >> >var re:ResultEvent = data as ResultEvent;
> > > >> >> >_assetHealthModel.data = re.result as Object;
> > > >> >> >trace(1);
> > > >> >> >}
> > > >> >> >
> > > >> >> >In Console I see
> > > >> >> >2
> > > >> >> >1
> > > >> >> >
> > > >> >> >but never 2 again.
> > > >> >> >
> > > >> >> >Hope, it's clear.
> > > >> >> >
> > > >> >> >Thanks
> > > >> >> >
> > > >> >> >
> > > >> >> >On Thu, Nov 13, 2014 at 12:37 PM, Alex Harui <aharui@adobe.com>
> > > >>wrote:
> > > >> >> >
> > > >> >> >>
> > > >> >> >>
> > > >> >> >> On 11/13/14, 10:04 AM, "mark goldin" <markzolotoy@gmail.com>
> > > >>wrote:
> > > >> >> >>
> > > >> >> >> >Here is singleton definition:
> > > >> >> >> >[Bindable]
> > > >> >> >> >public class ModelLocator extends EventDispatcher
implements
> > > >> >> >>IModelLocator
> > > >> >> >> >
> > > >> >> >> >All properties on that class are public vars.
> > > >> >> >>
> > > >> >> >> I’ll assume you are trying to tell me that they
are not public
> > > >>static
> > > >> >> >>vars?
> > > >> >> >>
> > > >> >> >> When we’ll need to know more about how the instance
is shared,
> > > >> >>whether
> > > >> >> >>you
> > > >> >> >> are getting warnings and compile time or runtime,
and probably
> > > >>more
> > > >> >> >> details about what the symptoms are.
> > > >> >> >>
> > > >> >> >> -Alex
> > > >> >> >>
> > > >> >> >>
> > > >> >>
> > > >> >>
> > > >>
> > > >>
> > >
> > >
> >
>

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