Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit b267cc8

Browse files
committed
Update Object.js
1 parent 8508bcd commit b267cc8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

modules/Object.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ module.factory('BaseObject', ($q) => {
3232
*/
3333
cache(name, callback, permanent = false) {
3434
// sets (truthy) flag reference to promise + avoids redundant calls
35-
return this[name] || ( this[name] = $q.when(callback())
35+
if (this[name])
36+
return this[name];
37+
38+
return this[name] = callback()
3639
// flag cleanup (doesn't affect chaining)
3740
.finally( () => {
3841
if (!permanent)
3942
this[name] = null;
40-
})
41-
);
43+
});
4244
}
4345

4446
/**

0 commit comments

Comments
 (0)