Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

dtInstances.getLast or getList #301

Closed
f0def opened this issue Apr 27, 2015 · 3 comments
Closed

dtInstances.getLast or getList #301

f0def opened this issue Apr 27, 2015 · 3 comments
Labels

Comments

@f0def
Copy link

f0def commented Apr 27, 2015

Hi
For what these two lines?

    function register(dtInstance, result) {
        //...some code before
        //new promise
        _deferDTInstances = $q.defer();
        _deferLastDTInstance = $q.defer();

        //THIS 2 LINES:
        _deferDTInstances.resolve(_instances);
        _deferLastDTInstance.resolve(_lastDTInstance);

        return dtInstance;
    }

this lines cause a bug

    function getLast() {
        var defer = $q.defer();
        _deferLastDTInstance.promise.then(function(lastInstance) {
            //NOT CALLED
            defer.resolve(lastInstance);
        });
        return defer.promise;
    }

because defer.resolve(lastInstance); not called after navigate in SPA
This leads to that the user handler not invoked, ex:

    DTInstances.getLast().then(function (dtInstance) {
      $scope.dtInstance = dtInstance;
    });
@l-lin
Copy link
Owner

l-lin commented Apr 28, 2015

It was to solved in this issue.
Unfortunately, I do not reproduce your issue. The promise in my case is always resolved. Can you provide a plunker or something alike that reproduce your issue?

@f0def
Copy link
Author

f0def commented Apr 28, 2015

@l-lin thanks for the answer
I have prepared an example, see here. Steps to reproduce inside the example.

@l-lin
Copy link
Owner

l-lin commented May 8, 2015

With the enhancement #307, I solved your issue in this plnkr.

@l-lin l-lin added the wontfix label May 8, 2015
@l-lin l-lin closed this as completed May 17, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants