this isnt 100% puremvc related, but I was wondering how people here handled this.
1) load a list of Authors and store them in authorList:ArrayCollection
2) Load a list of Books and store them in books:ArrayCollection
now, lets assume a book object is composed of an author object.
The author objects that the books refer to, are different instances than the authors in authorList. The reasoning makes sense, the framework has no idea it has received that Author object before via a completely different proxy, so it just creates a new one. This breaks when a user modifies an author via a book, then goes to look at the list of authors, only to find their changes weren't applied to that list!
I am currently registering the RECEIVED_BOOK_LIST notification to a command class (NormalizeAuthorsCommand) that loops through the list it just received, finds the correct Author object from the authorList, and replaces the reference in the Book. Once this is done, the command fires off a LOAD_BOOK_LIST_SUCCESSFUL. I'm building a rather large app (the author/book was just a simple example) and am finding myself doing this all over the place. I thought about not returning the whole author object with the book, but just the authorId. I think this would just save network chatter as I would still need to loop through the list, find the right author, and update the reference in the Book. I think either I am missing something or there has to be a better approach. How are you guys handling this?
Todd