@@ -6,33 +6,26 @@ import {
66} from '@angular/core' ;
77import { takeUntilDestroyed } from '@angular/core/rxjs-interop' ;
88import { provideMulti } from '@angularity/core' ;
9- import { from , ObservableInput , of } from 'rxjs' ;
9+ import { combineLatest , Observable } from 'rxjs' ;
1010
11- import { ThemeBuildConfig , ThemeManager } from './manager' ;
12-
13- /**
14- * Invoked within an injection context.
15- */
16- export interface ThemeBuildConfigFactory {
17- ( ) : ObservableInput < ThemeBuildConfig > ;
18- }
11+ import { ThemeBuilderComposition } from './builder-composition' ;
12+ import { ThemeManager } from './manager' ;
1913
2014export function provideTheme (
21- configInput : ThemeBuildConfig | ThemeBuildConfigFactory ,
15+ ... compositions : Observable < ThemeBuilderComposition > [ ]
2216) : EnvironmentProviders {
2317 return makeEnvironmentProviders ( [
2418 provideMulti ( {
2519 token : ENVIRONMENT_INITIALIZER ,
26- useFactory : ( themeManager = inject ( ThemeManager ) ) => {
27- const configSource =
28- typeof configInput === 'function' ? configInput ( ) : of ( configInput ) ;
29- return ( ) =>
30- from ( configSource )
20+ useFactory :
21+ ( manager = inject ( ThemeManager ) ) =>
22+ ( ) =>
23+ combineLatest ( compositions )
3124 . pipe ( takeUntilDestroyed ( ) )
32- . subscribe ( ( config ) => {
33- themeManager . buildAndApply ( config ) ;
34- } ) ;
35- } ,
25+ . subscribe ( ( compositions ) => {
26+ const tokens = manager . build ( compositions ) ;
27+ manager . apply ( tokens ) ;
28+ } ) ,
3629 } ) ,
3730 ] ) ;
3831}
0 commit comments