-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #408 from MRinaldi9/feat/integrate-modern-api-angular
Integration modern api angular
- Loading branch information
Showing
5 changed files
with
25 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
import { NgModule, ModuleWithProviders, InjectionToken } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { NgxIndexedDBService } from './ngx-indexed-db.service'; | ||
import { DBConfig, CONFIG_TOKEN } from './ngx-indexed-db.meta'; | ||
import { DBConfig } from './ngx-indexed-db.meta'; | ||
import { _provideIndexedDb } from './provide-indexed-db'; | ||
|
||
@NgModule({ | ||
declarations: [], | ||
imports: [CommonModule] | ||
}) | ||
@NgModule() | ||
export class NgxIndexedDBModule { | ||
static forRoot(...dbConfigs: DBConfig[]): ModuleWithProviders<NgxIndexedDBModule> { | ||
const value = {}; | ||
for (const dbConfig of dbConfigs) { | ||
Object.assign(value, {[dbConfig.name]: dbConfig}); | ||
} | ||
return { | ||
ngModule: NgxIndexedDBModule, | ||
providers: [NgxIndexedDBService, { provide: CONFIG_TOKEN, useValue: value }] | ||
providers: [..._provideIndexedDb(...dbConfigs)], | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { makeEnvironmentProviders, Provider } from '@angular/core'; | ||
import { DBConfig, CONFIG_TOKEN } from './ngx-indexed-db.meta'; | ||
import { NgxIndexedDBService } from './ngx-indexed-db.service'; | ||
|
||
export const provideIndexedDb = (...dbConfigs: DBConfig[]) => { | ||
return makeEnvironmentProviders([..._provideIndexedDb(...dbConfigs)]); | ||
}; | ||
|
||
export const _provideIndexedDb = (...dbConfigs: DBConfig[]): Provider[] => { | ||
const configs = dbConfigs.reduce<Record<string, DBConfig>>((acc, curr) => { | ||
acc[curr.name] = curr; | ||
return acc; | ||
}, {}); | ||
return [NgxIndexedDBService, { provide: CONFIG_TOKEN, useValue: configs }]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './lib/ngxindexeddb.module'; | ||
export * from './lib/ngx-indexed-db.service'; | ||
export * from './lib/ngx-indexed-db.meta'; | ||
export { provideIndexedDb } from './lib/provide-indexed-db'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters