Skip to content

Commit

Permalink
feat: Allow registration of load child views callback on view
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Aug 8, 2024
1 parent df4df29 commit b737a98
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/navigation/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ interface ViewData {
* haven't customized their sorting column
*/
defaultSortKey?: string

/**
* Method called to load child views if any
*/
// eslint-disable-next-line no-use-before-define
loadChildViews?: (view: View) => Promise<void>
}

export class View implements ViewData {
Expand Down Expand Up @@ -157,6 +163,10 @@ export class View implements ViewData {
return this._view.defaultSortKey
}

get loadChildViews() {
return this._view.loadChildViews
}

}

/**
Expand Down Expand Up @@ -222,5 +232,9 @@ const isValidView = function(view: ViewData): boolean {
throw new Error('View defaultSortKey must be a string')
}

if (view.loadChildViews && typeof view.loadChildViews !== 'function') {
throw new Error('View loadChildViews must be a function')
}

return true
}

0 comments on commit b737a98

Please sign in to comment.