angular-ui / AngularJS-StyleGuide

Example of scalable architecture for my NG-Conf 2014 talk
http://www.youtube.com/watch?v=Iw-3qgG_ipU
284 stars 53 forks source link

Why return a promise only sometimes? #3

Closed thomasstevens89 closed 10 years ago

thomasstevens89 commented 10 years ago

https://github.com/ProLoser/AngularJS-ORM/blob/master/modules/Objects.coffee#L74-88

Why does getProjects() return @projects inside a promise on line 77 but after having to query for the projects just returns @projects directly?

ProLoser commented 10 years ago

Sorry, I haven't seen this until now.

ProLoser commented 10 years ago

@thomasstevens89 it helps if you look at the generated Javascript, line 77 and line 79 both return promises. Line 77 is just a promise that is resolved immediately with the collection while line 79 is resolved upon response from the backend with whatever is returned on line 88.

thomasstevens89 commented 10 years ago

Thanks Dean. Still playing with my own implementation and trying to sort through everything. You've been very helpful