Skip to content

Commit 45f6f27

Browse files
Improve API and simplify cache method call
1 parent 3f8b912 commit 45f6f27

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/autocomplete.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,12 @@ class AutoComplete {
215215
this.DOMResults.setAttribute("class", "autocomplete open");
216216
}
217217

218-
var callback: any = function(response: string) {
219-
this._Render(this._Post(response));
220-
this._Open();
221-
}.bind(this);
222-
223218
AutoComplete.prototype.cache(
224219
this,
225-
AutoComplete.prototype.makeRequest(this, callback),
226-
callback
220+
function(response: string) {
221+
this._Render(this._Post(response));
222+
this._Open();
223+
}.bind(this)
227224
);
228225
}
229226
},
@@ -339,7 +336,7 @@ class AutoComplete {
339336
/**
340337
* Manage the cache
341338
*/
342-
_Cache: function(value: string): string|null {
339+
_Cache: function(value: string): string|undefined {
343340
return this.$Cache[value];
344341
},
345342

@@ -647,10 +644,12 @@ class AutoComplete {
647644
}
648645
}
649646

650-
cache(params: Params, request: XMLHttpRequest, callback: any): void {
651-
var response: string|null = params._Cache(params._Pre());
647+
cache(params: Params, callback: any): void {
648+
var response: string|undefined = params._Cache(params._Pre());
652649

653650
if (response === undefined) {
651+
var request: XMLHttpRequest = AutoComplete.prototype.makeRequest(params, callback);
652+
654653
AutoComplete.prototype.ajax(params, request);
655654
} else {
656655
callback(response);

0 commit comments

Comments
 (0)