Skip to content

Commit

Permalink
feat(navigation): add token for providing navigation in-memory seed d…
Browse files Browse the repository at this point in the history
…ata (#2627)
  • Loading branch information
griest024 authored Nov 30, 2023
1 parent 260332b commit a033da4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/navigation/driver/in-memory/src/public_api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export { DaffInMemoryBackendNavigationService } from './backend/navigation.service';
export { DaffInMemoryNavigationService } from './navigation.service';
export { DaffNavigationInMemoryDriverModule } from './navigation-driver.module';

export * from './seed-data-provider/public_api';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { DaffNavigationInMemorySeedDataProvider } from './type';
export * from './token';
21 changes: 21 additions & 0 deletions libs/navigation/driver/in-memory/src/seed-data-provider/token.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
InjectionToken,
ValueProvider,
} from '@angular/core';

import { DaffNavigationInMemorySeedDataProvider } from './type';

/**
* A token for providing a way for the navigation in-memory driver to seed its data from an external source.
*/
export const DAFF_NAVIGATION_IN_MEMORY_SEED_DATA_PROVIDER = new InjectionToken<DaffNavigationInMemorySeedDataProvider>('DAFF_NAVIGATION_IN_MEMORY_SEED_DATA_PROVIDER');

/**
* Provides {@link DAFF_NAVIGATION_IN_MEMORY_SEED_DATA_PROVIDER}.
*/
export function daffProvideNavigationInMemorySeedDataProvider(provider: DaffNavigationInMemorySeedDataProvider): ValueProvider {
return {
provide: DAFF_NAVIGATION_IN_MEMORY_SEED_DATA_PROVIDER,
useValue: provider,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { DaffNavigationTree } from '@daffodil/navigation';

/**
* A function that fetches and returns the root navigation tree for the in-memory driver.
*/
export type DaffNavigationInMemorySeedDataProvider = () => DaffNavigationTree;

0 comments on commit a033da4

Please sign in to comment.