0

I try to have an object with some immutable properties which initiate at the constructor and won't be able to change after initiation. Those properties then only have getter method. Since I want this object can be shared with other classes, I save it to the SharedObject class called saveIt().

All work fine when running the app on iOS (I do not test it on Android yet) except that if I completely shutdown the app from memory and reopen it, those properties' without setter are lost. The code is as below:

          var rooms:ArrayCollection = saveData.read("rooms") as ArrayCollection;
          if (!roomExists) {
                var room:Room;
                room = new Room(myID, myName, maxRoomSize);

                room.name = rm.name;
                room.timestamp = new Date();
                room.joinUrl = rm.joinUrl;
                room.attendeeUrl = rm.attendeeUrl;
                room.attendees = conferenceParameters.metadata.hasOwnProperty("attendees") ? conferenceParameters.metadata["attendees"] : null;

                rooms.addItem(room);
            }
            saveIt.save("rooms", rooms);
Feng David
  • 119
  • 3
  • did you **flush** the SharedObject after saving any thing? – payam_sbr Feb 23 '17 at 02:16
  • I flush the SharedObject and then read it back, it's ok if the app keep alive or the properties without setter will lost. It can be reproduced by set two sets of properties, one with setter the others not. The properties with setter will always exist while others will not. – Feng David Feb 23 '17 at 04:54

1 Answers1

0

I found if I assign a dummy setter for each of the immutable properties i.e.

    function set myID(s:String):void{}

then it can be safely saved even I shutdown the app. Since I can't find any information about this code behavior, so I'd like to look for opinions here!!

Feng David
  • 119
  • 3