aaronksaunders / AppC-Alloy-Book

Complete and updated source code for the book Building Cross-Platform Apps using Titanium, Alloy, and Appcelerator Cloud Services
http://www.clearlyinnovative.com/build-it/
Other
26 stars 12 forks source link

Question about an explanation for loadPhotos function #3

Open frodfigu opened 9 years ago

frodfigu commented 9 years ago

Hello again Aaron,

congratulations for your book, its very interesting for me. I´m trying to understand some lines of code in a loadPhotos function in the feed.js. So, photos.fetch backbone call goes to processACSPhotos to the use case read, ok, so when the ACS method Cloud.Photos.query returns a collection of photos you pass them on option.success(e.photos). In the feed.js code after this calls you have a success function which needs two parameters (model, response). How the photos var gets the content that you passing in option.success(e.photos) in the sync adapter?

Thank you very much for your time.

Several hours with this. I know that you´ve created a collection instance global by this line var photos = Alloy.Collections.photo || Alloy.Collections.instance("photo"); in the feed.js, but so I don´t know why you need pass the collection by option.success(e.photos).

aaronksaunders commented 9 years ago

that is how the magic of BackboneJS works, if we dont set that in the sync adapter, the collection will bot be properly updated. Is there a specific bug you are finding?

BTW it would be great if you could provide a review on Amazon for the book, reviews help raise awareness of Appcelerator Alloy, and are greatly appreciated.