angular-poller icon indicating copy to clipboard operation
angular-poller copied to clipboard

poller.get doesn't create new pollers for multiple Restangular objects

Open mkdbns opened this issue 10 years ago • 2 comments

Hi,

Thanks for this nice library! I think I found an issue with how you're doing the poller lookup (angular.equals). It doesn't seem to work for Restangular objects. Two different objects (different routes) will return true with angular.equals - thus I can't create multiple Restangular pollers. Here is a test case:

    describe('if poller is not registered yet,', function () {

      var r1, r2, r1poller, r2poller;

        beforeEach(function () {

            r1 = Restangular.all('admin');
            r2 = Restangular.all('users');

            r1poller = poller.get(r1, {
              action: 'getList',
              argumentsArray: [],
              delay: 100000
            });


            r2poller = poller.get(r2, {
              action: 'getList',
              argumentsArray: [],
              delay: 100000
            });

        });

        // Passes
        it('should compare properly', function () {
            expect(r1).to.not.equal(r2);
        });

        // Fails
        it('should not be angular.equal', function () {
            expect(angular.equals(r1,r2)).to.equal(false);
        });

        // Fails
        it('should create new poller on invoking get().', function () {
            expect(r1poller).to.not.equal(r2poller);
        });

        // Fails
        it('should increase poller registry size by one.', function () {
            expect(poller.size()).to.equal(2);
        });
    });

mkdbns avatar Dec 30 '14 23:12 mkdbns

Thanks for writing the detailed test case! You are right - angular.equals always returns true when comparing two Restangular.all objects. I've submitted an issue to Restangular https://github.com/mgonto/restangular/issues/992.

emmaguo avatar Jan 06 '15 00:01 emmaguo

Hello @emmaguo , I believe I am having this problem. A bit surprised this thread is so old??? Did this get fixed?

I am creating multiple pollers with Restangular objects, and strangely the requests are sort of merging, where the first poller is making the request with its url and the second pollers params, and the second poller is not requesting at all.

xaun avatar Feb 15 '19 04:02 xaun