angular-app/Samples — pull request #3 by petebacondarwin (2012-12-13 22:10:53+00:00)
Title: Pizza Promises

Hi Pawel

I had a little play around with the first half of the samples. I found it a bit difficult to follow, terms like promise and defer and propagate and reject made it difficult to scan. And I claim to understand $q!

I thought it would be easier to have a pizza restaurant as an object that provided the promise and did the resolving and rejecting within functions that meant something in the problem domain.
Also I like Pizza!

You'll also note that I ditched the prototype declarations. I did this for three reasons.

- I think that it is easier to read (and shorter due to the use of closer rather than this) for this sample
- AngularJS tends to encourage a similar style for creating Controllers and Singleton services
- It lets you get away from using `this`, which means you can write terse stuff like `promisedOrder.then(pawel.eat)` without worrying about binding the `this` correctly.

Of course I realise that for things like Person you really shouldn't be creating a new set of functions for each instance but in this case it just looks nice.

Let me know what you think.

Pete