mgonto / restangular

AngularJS service to handle Rest API Restful Resources properly and easily
MIT License
7.87k stars 840 forks source link

Make addRestangularMethod return the Object #732

Open luaks opened 10 years ago

luaks commented 10 years ago

I think it would be great, if addRestangularMethod would return the Object it is called on. This way pure restangular services with extended methods would get a lot easier to write.

instead of this:

function (Restangular) {
    var Books = Restangular.all('api/books');

    Books.addRestangularMethod('getRandoomBook', 'get', 'random');

    return Books;
}

You would only have to write this:

function (Restangular) {
    return Restangular.all('api/books')
        .addRestangularMethod('getRandoomBook', 'get', 'random');
}

which looks a lot nicer and is a lot cleaner in my oppinion

mgonto commented 10 years ago

This makes a lot of sense. 

I'll implement this! 

Thanks for the report — Sent from Mailbox

On Wed, May 28, 2014 at 4:26 AM, Lukas Peleska notifications@github.com wrote:

I think it would be great, if addRestangularMethod would return the Object it is called on. This way pure restangular services with extended methods would get a lot easier to write. instead of this: js function (Restangular) { var Books = Restangular.all('api/books'); Books.addRestangularMethod('getRandoomBook', 'get', 'random'); return Books; } You would only have to write this: js function (Restangular) { return Restangular.all('api/books') .addRestangularMethod('getRandoomBook', 'get', 'random'); }

which looks a lot nicer and is a lot cleaner in my oppinion

Reply to this email directly or view it on GitHub: https://github.com/mgonto/restangular/issues/732

grabbou commented 9 years ago

Everybody loves chaining!