cachedValue.js 428 B

12345678910111213141516171819202122
  1. var emptyValue = '';
  2. Mixins.CachedValue = BlazeComponent.extendComponent({
  3. onCreated: function() {
  4. this._cachedValue = emptyValue;
  5. },
  6. setCache: function(value) {
  7. this._cachedValue = value;
  8. },
  9. getCache: function(defaultValue) {
  10. if (this._cachedValue === emptyValue)
  11. return defaultValue || '';
  12. else
  13. return this._cachedValue;
  14. },
  15. resetCache: function() {
  16. this.setCache('');
  17. }
  18. });