restangular icon indicating copy to clipboard operation
restangular copied to clipboard

Wrap object as a promise

Open f0def opened this issue 9 years ago • 8 comments

To wrap object as a angular promise i can use $q.when

var _data;//lazy or eager strategy
function getData(){
  if (!this._data){
    _data = $http.get('data.json');
  }else{
    _data = $q.when(_data);
  }
  return _data;
}

I need to be sure that i always dealing with a promise from getData() method. How can i do same for restangular with it private restangularizePromise() method?

f0def avatar Mar 06 '15 07:03 f0def

I have no idea what you're trying to do. Can you provide a more concrete example?

daviesgeek avatar Jun 17 '16 23:06 daviesgeek

Year has passed, long overdue :)

f0def avatar Jun 21 '16 05:06 f0def

My apologies. The original author of this project has passed it on, so I and a couple of other people are trying to clean it up. There are so many issues to go through right now that it's been hard keeping up.

daviesgeek avatar Aug 31 '16 02:08 daviesgeek

Is this still an issue for you?

daviesgeek avatar Aug 31 '16 02:08 daviesgeek

no, you can close

f0def avatar Aug 31 '16 10:08 f0def

Hi f0def, how did you manage to solve your problem? I'm having similar issue.

htao00 avatar Apr 04 '17 12:04 htao00

Sorry, but no, I dropped this angular project, now I use the react :)

f0def avatar Apr 04 '17 13:04 f0def

Nvm I think I figured out. You can do this.

var _data = null;
function getData() {
  if (_data) { return _data; }
   _data = Restangular.get(); 
  return _data;
}

htao00 avatar Apr 04 '17 13:04 htao00