Skip to content

Commit

Permalink
emit only on changed value
Browse files Browse the repository at this point in the history
  • Loading branch information
madhur-tandon committed Mar 17, 2022
1 parent 5f6ef02 commit 0e61890
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions src/searchReplace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,47 @@ export class SearchReplaceModel extends VDomModel {
}

set caseSensitive(v: boolean) {
this._caseSensitive = v;
this.stateChanged.emit();
this._debouncedStartSearch
.invoke()
.catch(reason => console.error(`failed query for ${v} due to ${reason}`));
if (v !== this._caseSensitive) {
this._caseSensitive = v;
this.stateChanged.emit();
this._debouncedStartSearch
.invoke()
.catch(reason =>
console.error(`failed query for ${v} due to ${reason}`)
);
}
}

get wholeWord(): boolean {
return this._wholeWord;
}

set wholeWord(v: boolean) {
this._wholeWord = v;
this.stateChanged.emit();
this._debouncedStartSearch
.invoke()
.catch(reason => console.error(`failed query for ${v} due to ${reason}`));
if (v !== this._wholeWord) {
this._wholeWord = v;
this.stateChanged.emit();
this._debouncedStartSearch
.invoke()
.catch(reason =>
console.error(`failed query for ${v} due to ${reason}`)
);
}
}

get useRegex(): boolean {
return this._useRegex;
}

set useRegex(v: boolean) {
this._useRegex = v;
this.stateChanged.emit();
this._debouncedStartSearch
.invoke()
.catch(reason => console.error(`failed query for ${v} due to ${reason}`));
if (v !== this._useRegex) {
this._useRegex = v;
this.stateChanged.emit();
this._debouncedStartSearch
.invoke()
.catch(reason =>
console.error(`failed query for ${v} due to ${reason}`)
);
}
}

get queryResults(): IResults[] {
Expand Down

0 comments on commit 0e61890

Please sign in to comment.