UNPKG

2.93 kBJavaScriptView Raw
1/**
2 * ag-grid - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
3 * @version v18.1.2
4 * @link http://www.ag-grid.com/
5 * @license MIT
6 */
7"use strict";
8var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
9 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12 return c > 3 && r && Object.defineProperty(target, key, r), r;
13};
14var __metadata = (this && this.__metadata) || function (k, v) {
15 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
16};
17Object.defineProperty(exports, "__esModule", { value: true });
18var context_1 = require("../context/context");
19var gridOptionsWrapper_1 = require("../gridOptionsWrapper");
20var ValueCache = (function () {
21 function ValueCache() {
22 this.cacheVersion = 0;
23 }
24 ValueCache.prototype.init = function () {
25 this.active = this.gridOptionsWrapper.isValueCache();
26 this.neverExpires = this.gridOptionsWrapper.isValueCacheNeverExpires();
27 };
28 ValueCache.prototype.onDataChanged = function () {
29 if (this.neverExpires) {
30 return;
31 }
32 this.expire();
33 };
34 ValueCache.prototype.expire = function () {
35 this.cacheVersion++;
36 };
37 ValueCache.prototype.setValue = function (rowNode, colId, value) {
38 if (this.active) {
39 if (rowNode.__cacheVersion !== this.cacheVersion) {
40 rowNode.__cacheVersion = this.cacheVersion;
41 rowNode.__cacheData = {};
42 }
43 rowNode.__cacheData[colId] = value;
44 }
45 };
46 ValueCache.prototype.getValue = function (rowNode, colId) {
47 var valueInCache = this.active
48 && rowNode.__cacheVersion === this.cacheVersion
49 && rowNode.__cacheData[colId] !== undefined;
50 if (valueInCache) {
51 return rowNode.__cacheData[colId];
52 }
53 else {
54 return undefined;
55 }
56 };
57 __decorate([
58 context_1.Autowired('gridOptionsWrapper'),
59 __metadata("design:type", gridOptionsWrapper_1.GridOptionsWrapper)
60 ], ValueCache.prototype, "gridOptionsWrapper", void 0);
61 __decorate([
62 context_1.PostConstruct,
63 __metadata("design:type", Function),
64 __metadata("design:paramtypes", []),
65 __metadata("design:returntype", void 0)
66 ], ValueCache.prototype, "init", null);
67 ValueCache = __decorate([
68 context_1.Bean('valueCache')
69 ], ValueCache);
70 return ValueCache;
71}());
72exports.ValueCache = ValueCache;