Promises and chocolate chip cookies


#1

Maybe I am missing something obvious here. I feel like I understand the basic idea of promises. But trying to get a handle on the function syntax.

I created an example where I tried to work it out in code in a very verbose way.

http://jsbin.com/AceBuTE/1/

Here is example where I try to resolve the promise earlier in the getCookie function

Here is another variant

Seems the part I am struggling with conceptually is how to resolve the the promise and pass it around.

Why can’t I get the chocolate chip cookies I am promised?


#2

A more refined example of the basic concept.

Ember JS Cookie Maker without async

purely synchronous example to show the basic behavior (deliberately using basic object model)

Ember JS Cookie Maker with async and promises

Can’t quite get the promise part worked out.

Sorry for crosspost. I asked my question on SO.


#3

Resolved!!! Thanks Mike Grassotti for help! http://stackoverflow.com/users/983357/mike-grassotti

This might be a useful promise example for others to get their minds around async operations.