Skip to content

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

Open
@theBull

Description

@theBull

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions