This project has moved. For the latest updates, please go here.

promises

The linq2indexedDB.promises exposes an object which is a wrapper around a given promise object. This can be jQuery implementation or WinJS implementation. More information can be found on this blogpost.

It is also possible to plugin your own promise object.

Own promise provider

  1. Extend the linq2indexedDB.promises namespace with a promise function accepting a callback function.
  2. Create a new Promise of your own promise
  3. Invoke the callback function inside the yout own promise. And provide an object with the following functions. All functions have 2 parameters, the context and an array args containing all arguments passed.
    1. complete: calls the complete callback of your own promise inside.
    2. error: calls the error callback of your own promise inside.
    3. progrress: calls the progress callback of your own promise inside.

function customPromise(callback) {
     return new CustomPromise(function(completed, error, progress) {
         callback({
             complete: function(context, args) {
                 completed(args);
             },
             error: function(context, args) {
                 error(args);
             },
             progress: function(context, args) {
                 progress(args);
             }
         });
     });
}

linq2indexedDB.promises = {
     promise: customPromise
};

Last edited Feb 19, 2014 at 7:46 PM by KDegrave, version 1

Comments

No comments yet.