question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a clean way I can know if given object is 'restangularized'?

See original GitHub issue

Hi. Basically, I have situation where I have to know if object passed to the function is restangularized or not, it might be a collection or a single element.

I was thinking about two options.

First option, adding isRestangularized boolean property to each response via RestangularProvider.setResponseExtractor() However, there is a problem with it, object can ‘by pass’ intercepter, for instance I can create restangularized element using Restangular.restangularizeElement() and it will not contain my isRestangularized property.

As second option, I can look for restangular properties that exist both in collections and elements such as addRestangularMethod by doing object.hasOwnProperty('addRestangularMethod') check.

Is there a better way? (using 1.4.0 version of Restangular)

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dreef3commented, Dec 19, 2015

AFAIK there’s a restangularized boolean property already. You can check for it.

0reactions
nicolas-zozolcommented, Aug 31, 2016

Sorry I was wrong. Using Restangular 1.5.2, I have the field restangularized.

restangularized

Read more comments on GitHub >

github_iconTop Results From Across the Web

get original data object from response · Issue #667 - GitHub
Hey,. You can use actually Restangular.stripRestangular(response) and that way you'll get the empty response without any Restangular method.
Read more >
Restangular get clean response object from POST request
You can get the plain element using .plain() from response this.Restangular.one("auth").post("login",data).then(function(resp){ ...
Read more >
restangular - npm
When I set baseUrl with a port, it's stripped out. How can I access the unrestangularized element as well as the restangularized one?...
Read more >
Restangular: New AngularJS framework to handle Rest API ...
I've been working with AngularJS this past months and I've extracted one service that I've created to facilitate the usage of Restful Resources....
Read more >
Discussion of Comments Are The Only "Code Smell" - DEV ...
typeof null is 'object' function getType(value){ if(value === null) return ... I'm open to knowing alternative ways to give myself hints on what...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found