webcss / angular-indexedDB

An angularjs serviceprovider to utilize indexedDB with angular
149 stars 99 forks source link

Code mistakes ? #3

Closed JeffPsymot closed 11 years ago

JeffPsymot commented 11 years ago

Hello, as I'm new to javascript and angular, I learn it by reading your code and I wonder if what I see as mistakes is real ones or just the conséquence of my ignorance :

Thank your very much for giving access to your code ! It's a great help to see real programming !

webcss commented 11 years ago

Hi, and thanks for taking my humble code as a learning ground! You're right, it should be req = store.add(item). Thanks for shooting that bug, applied.

For lines 315 and 377, no, this isn't a mistake. What's passed around here is an angularjs promise. The resolving function '.then' returns a promise itself, which is then resolved by the req.onerror or req.unsuccess callback.

You can read more about this topic in the angularjs documentation: http://docs.angularjs.org/api/ng.$q.

Don't worry, I've had a hard time myself getting a grip on promises!