Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow registration of load child views callback on view #1046

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading