mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Support list as a function
This commit is contained in:
parent
6e51ff67d8
commit
2dbf9e3d26
1 changed files with 12 additions and 1 deletions
|
|
@ -1,11 +1,21 @@
|
||||||
export const defaultPerPage = 20
|
export const defaultPerPage = 20
|
||||||
|
|
||||||
|
|
||||||
export class PaginatedList {
|
export class PaginatedList {
|
||||||
constructor({ list, perPage = defaultPerPage }) {
|
constructor({ list, perPage = defaultPerPage }) {
|
||||||
this.list = list
|
this.listArg = list
|
||||||
this.perPage = perPage
|
this.perPage = perPage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get list () {
|
||||||
|
// if our list is a function, call it
|
||||||
|
if ( typeof this.listArg === 'function' ) {
|
||||||
|
return this.listArg()
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.listArg
|
||||||
|
}
|
||||||
|
|
||||||
get total () {
|
get total () {
|
||||||
return this.list.length
|
return this.list.length
|
||||||
}
|
}
|
||||||
|
|
@ -46,3 +56,4 @@ export class PaginatedList {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue