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.

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?

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.

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.

1 Like