Skip to content

Commit 4b78961

Browse files
committed
style: format
1 parent 79bc534 commit 4b78961

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/AdapSearchfield.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,32 @@ const template = `
33
v-if="collection"
44
class="adap-searchfield"
55
v-model="collection.search"
6-
@keyup="collection.querySearch()"
6+
@keyup="search"
77
/>
88
`
99

1010
import { Component, Prop, Vue } from 'vue-property-decorator'
1111
import { PageCollection, IResource } from '@simpli/resource-collection'
1212

13+
const debounce = require('lodash.debounce')
14+
1315
@Component({ template })
1416
export class AdapSearchfield extends Vue {
1517
@Prop({ required: true })
1618
collection!: PageCollection<IResource>
19+
20+
@Prop({ type: Number, default: 1000 })
21+
debounceTimer!: number
22+
23+
get querySearch(): () => Promise<any> {
24+
return debounce(() => this.debounceQuerySearch(), this.debounceTimer)
25+
}
26+
27+
async debounceQuerySearch() {
28+
await this.collection.querySearch()
29+
}
30+
31+
async search() {
32+
await this.querySearch()
33+
}
1734
}

0 commit comments

Comments
 (0)