From b737a989a13ab8947fdbca66cad8f1a1330dedc6 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Wed, 7 Aug 2024 20:45:16 -0700 Subject: [PATCH] feat: Allow registration of load child views callback on view Signed-off-by: Christopher Ng --- lib/navigation/view.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/navigation/view.ts b/lib/navigation/view.ts index 8c8a33d8..911aab32 100644 --- a/lib/navigation/view.ts +++ b/lib/navigation/view.ts @@ -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 } export class View implements ViewData { @@ -157,6 +163,10 @@ export class View implements ViewData { return this._view.defaultSortKey } + get loadChildViews() { + return this._view.loadChildViews + } + } /** @@ -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 }