Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the DbQ object really necessary? Why not just use $q #39

Open
theBull opened this issue Jun 25, 2015 · 2 comments
Open

Is the DbQ object really necessary? Why not just use $q #39

theBull opened this issue Jun 25, 2015 · 2 comments
Labels

Comments

@theBull
Copy link

theBull commented Jun 25, 2015

I found the deleteDatabase method wasn't deleting my database correctly; it was clearing the stores I had contained within it but not deleting the database itself. The approach used is a little puzzling - why does this service make use of a DbQ wrapper, and why this functionality is needed over the $q service that comes with angular? Maybe I'm missing something...

original (not working as expected)

deleteDatabase: function () {
    return closeDatabase().then(function () {
        var defer;
        defer = new DbQ();
        defer.resolveWith(indexedDB.deleteDatabase(dbName));
            return defer.promise;
        })["finally"](function () {
            return $log.log("$indexedDB: " + dbName + " database deleted.");
        });
    }

modified (working)

deleteDatabase: function () {
    return closeDatabase().then(function() {
        var deferred = $q.defer();

        indexedDB.deleteDatabase(dbName).then(function (result) {
            console.log("$indexedDB: " + dbName + " database deleted.")
            deferred.resolve(result);
        }).catch(function(error) {
            deferred.reject(error);
        });

        return defer.promise;
    });
}

Is it just outdated? I can submit a pull request if you'd like.

@theBull theBull changed the title Is the DbQ really necessary? Why not just use $q.defer() Is the DbQ object really necessary? Why not just use $q.defer() Jun 25, 2015
@theBull theBull changed the title Is the DbQ object really necessary? Why not just use $q.defer() Is the DbQ object really necessary? Why not just use $q Jun 25, 2015
@bramski
Copy link
Owner

bramski commented Jun 25, 2015

Artifact from the original developer. It's probably unnecessary for
deletion. Was necessary for some of the other functions. Please do submit
a PR. Please make sure you modify the coffee source and not the compiled
JS.
On Jun 24, 2015 10:39 PM, "Danny Bullis" [email protected] wrote:

I found the deleteDatabase method wasn't deleting my database correctly;
it was clearing the stores I had contained within it but not deleting the
database itself. The approach used is a little puzzling - why does this
service make use of the DbQ wrapper around the $q service built into
angular?

original (not working as expected)

deleteDatabase: function () {
return closeDatabase().then(function () {
var defer;
defer = new DbQ();
defer.resolveWith(indexedDB.deleteDatabase(dbName));
return defer.promise;
})["finally"](function %28%29 {
return $log.log%28"$indexedDB:);
});
}

modified (working)

deleteDatabase: function () {
return closeDatabase().then(function() {
var deferred = $q.defer();

    indexedDB.deleteDatabase(dbName).then(function (result) {
        console.log("$indexedDB: " + dbName + " database deleted.")
        deferred.resolve(result);
    }).catch(function(error) {
        deferred.reject(error);
    });

    return defer.promise;
});

}

Is it just outdated? I can submit a pull request if you'd like.


Reply to this email directly or view it on GitHub
#39.

@bramski
Copy link
Owner

bramski commented Jun 25, 2015

Please also write a test to ensure that deleteDatabase in the end does do as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants