This repository was archived by the owner on Nov 22, 2024. It is now read-only.
File tree 1 file changed +25
-9
lines changed
modules/universal/src/browser
1 file changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ export class OpaqueToken {
42
42
const SharedStylesHost : any = __platform_browser_private__ . SharedStylesHost ;
43
43
44
44
export const UNIVERSAL_CACHE = new OpaqueToken ( 'UNIVERSAL_CACHE' ) ;
45
+ export const AUTO_PREBOOT = new OpaqueToken ( 'AUTO_PREBOOT' ) ;
45
46
46
47
@NgModule ( {
47
48
imports : [
@@ -76,16 +77,23 @@ export const UNIVERSAL_CACHE = new OpaqueToken('UNIVERSAL_CACHE');
76
77
} ,
77
78
deps : [ ]
78
79
} ,
80
+ {
81
+ provide : AUTO_PREBOOT ,
82
+ useValue : true
83
+ } ,
79
84
{
80
85
multi : true ,
81
86
provide : APP_BOOTSTRAP_LISTENER ,
82
- useValue : ( ) => {
83
- let _win : any = window ;
84
- if ( _win && prebootClient ) {
85
- setTimeout ( ( ) => prebootClient ( ) . complete ( ) ) ;
86
- }
87
- }
88
- }
87
+ useFactory : ( autoPreboot : boolean ) => {
88
+ return ( ) => {
89
+ let _win : any = window ;
90
+ if ( _win && prebootClient && autoPreboot ) {
91
+ setTimeout ( ( ) => prebootClient ( ) . complete ( ) ) ;
92
+ }
93
+ } ;
94
+ } ,
95
+ deps : [ AUTO_PREBOOT ] ,
96
+ } ,
89
97
]
90
98
} )
91
99
export class UniversalModule {
@@ -101,10 +109,18 @@ export class UniversalModule {
101
109
} ) ;
102
110
}
103
111
static withConfig ( _config : any = { } ) : { ngModule : UniversalModule , providers : any [ ] } {
112
+ const providers = [ ] ;
113
+
114
+ if ( typeof _config . autoPreboot === 'boolean' ) {
115
+ providers . push ( {
116
+ provide : AUTO_PREBOOT ,
117
+ useValue : _config . autoPreboot ,
118
+ } ) ;
119
+ }
120
+
104
121
return {
105
122
ngModule : UniversalModule ,
106
- providers : [
107
- ]
123
+ providers : providers ,
108
124
} ;
109
125
}
110
126
}
You can’t perform that action at this time.
0 commit comments