diff options
-rw-r--r-- | src/webpack/webpack.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index 0bbd815..e537740 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -50,6 +50,8 @@ export const filters = { } return true; }, + byDisplayName: (name: string): FilterFn => m => + m.constructor?.displayName === name }; export const subscriptions = new Map<FilterFn, CallbackFn>(); @@ -327,6 +329,20 @@ export function findByCodeLazy(...code: string[]) { } /** + * Find a store by its displayName + */ +export function findByDisplayName(name: string) { + return find(filters.byDisplayName(name)); +} + +/** + * findByDisplayName but lazy + */ +export function findByDisplayNameLazy(name: string) { + return findLazy(filters.byDisplayName(name)); +} + +/** * Wait for a module that matches the provided filter to be registered, * then call the callback with the module as the first argument */ |