Skip to content

Commit

Permalink
Remove volatile computed properties (#207)
Browse files Browse the repository at this point in the history
Volatile computed properties are deprecated (https://deprecations-app-prod.herokuapp.com/deprecations/v3.x/#toc_computed-property-volatile). These were only used internally, so they can safely be converted to methods.
  • Loading branch information
Ben Demboski authored and marcoow committed Mar 7, 2019
1 parent fead831 commit fc8d683
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions addon/services/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default Service.extend({
return document;
}),

_documentCookies: computed(function() {
_getDocumentCookies() {
let all = this.get('_document.cookie').split(';');
let filtered = this._filterDocumentCookies(A(all));

Expand All @@ -35,9 +35,9 @@ export default Service.extend({
}
return acc;
}, {});
}).volatile(),
},

_fastBootCookies: computed(function() {
_getFastBootCookies() {
let fastBootCookies = this.get('_fastBoot.request.cookies');
fastBootCookies = A(keys(fastBootCookies)).reduce((acc, name) => {
let value = fastBootCookies[name];
Expand All @@ -50,17 +50,17 @@ export default Service.extend({
this._fastBootCookiesCache = fastBootCookies;

return this._filterCachedFastBootCookies(fastBootCookies);
}).volatile(),
},

read(name, options = {}) {
options = assign({}, DEFAULTS, options || {});
assert('Domain, Expires, Max-Age, and Path options cannot be set when reading cookies', isEmpty(options.domain) && isEmpty(options.expires) && isEmpty(options.maxAge) && isEmpty(options.path));

let all;
if (this.get('_isFastBoot')) {
all = this.get('_fastBootCookies');
all = this._getFastBootCookies();
} else {
all = this.get('_documentCookies');
all = this._getDocumentCookies();
}

if (name) {
Expand Down Expand Up @@ -99,9 +99,9 @@ export default Service.extend({
exists(name) {
let all;
if (this.get('_isFastBoot')) {
all = this.get('_fastBootCookies');
all = this._getFastBootCookies();
} else {
all = this.get('_documentCookies');
all = this._getDocumentCookies();
}

return all.hasOwnProperty(name);
Expand Down

0 comments on commit fc8d683

Please sign in to comment.