Promises and chocolate chip cookies

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

http://jsbin.com/ARugiBI/1/edit

Here is another variant

http://jsbin.com/omukolA/1/edit

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?

A more refined example of the basic concept.

Ember JS Cookie Maker without async

http://jsbin.com/iSacev/1/edit

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

Ember JS Cookie Maker with async and promises

http://jsbin.com/udeXoSE/1/edit

Can’t quite get the promise part worked out.

Sorry for crosspost. I asked my question on SO.

Resolved!!! Thanks Mike Grassotti for help! User Mike Grassotti - Stack Overflow

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

https://gist.github.com/eccegordo/6260354

1 Like