summaryrefslogtreecommitdiffstats
path: root/client/components/forms/cachedValue.js
blob: a2898d85b3a780f95c1592ac0ee71c6c2b28cd22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var emptyValue = '';

Mixins.CachedValue = BlazeComponent.extendComponent({
  onCreated: function() {
    this._cachedValue = emptyValue;
  },

  setCache: function(value) {
    this._cachedValue = value;
  },

  getCache: function(defaultValue) {
    if (this._cachedValue === emptyValue)
      return defaultValue || '';
    else
      return this._cachedValue;
  },

  resetCache: function() {
    this.setCache('');
  }
});