generic async callback function
<pre><code>    this.init = function (onupgradeneeded, onsuccess) {

        var openRequest = indexedDB.open(dbName);

        openRequest.onupgradeneeded = function (e) {

            db = e.target.result;

            if (!db.objectStoreNames.contains(objectStoreName)) {

                console.log('Creating the ' + objectStoreName + ' objectstore');

                db.createObjectStore(objectStoreName, { keyPath: "id", autoIncrement: true });

            }

        };

        openRequest.onsuccess = function (e) {

            db = e.target.result;

            db.onerror = function (event) {
                // Generic error handler for all errors targeted at this database requests
                console.log("Database error: " + event.target.errorCode);
            };
        };

    };
</code></pre>

<p>Called by:</p>

<pre><code>var idb = new Demo.IndexedDB();
idb.init();
</code></pre>

<p>When the init function runs, it will either end up in <code>openRequest.onupgradeneeded</code> or <code>openRequest.onsuccess</code>.</p>

<p>What i would like to know is if its possible to create a generic callback function that gets called in both function. So regardless of which of the two functions that runs i can know when theyre done by using</p>

<pre><code>idb.init(function(){
    //onupgradeneeded or onsuccess completed
});
</code></pre>

<p>Hope you get the idea, otherwise ill elaborate.</p>

<p>Thanks</p>
