-
-
Notifications
You must be signed in to change notification settings - Fork 241
feat: HMR bootstrap and livesync options #1531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,11 +50,18 @@ if ((<any>global).___TS_UNUSED) { | |
return InjectionToken; | ||
})(); | ||
} | ||
|
||
export interface HmrOptions { | ||
moduleTypeFactory?: () => Type<any> | NgModuleFactory<any> | ||
livesyncCallback: (bootstrapPlatfrom: () => void) => void; | ||
} | ||
|
||
export interface AppOptions { | ||
bootInExistingPage?: boolean; | ||
cssFile?: string; | ||
startPageActionBarHidden?: boolean; | ||
createFrameOnBootstrap?: boolean; | ||
hmr?: HmrOptions; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion:
I thought |
||
} | ||
|
||
export type PlatformFactory = (extraProviders?: StaticProvider[]) => PlatformRef; | ||
|
@@ -91,7 +98,9 @@ export class NativeScriptPlatformRef extends PlatformRef { | |
|
||
@profile | ||
bootstrapModuleFactory<M>(moduleFactory: NgModuleFactory<M>): Promise<NgModuleRef<M>> { | ||
this._bootstrapper = () => this.platform.bootstrapModuleFactory(moduleFactory); | ||
this._bootstrapper = () => this.platform.bootstrapModuleFactory( | ||
this.appOptions.hmr ? <NgModuleFactory<M>>this.appOptions.hmr.moduleTypeFactory() : moduleFactory | ||
); | ||
|
||
this.bootstrapApp(); | ||
|
||
|
@@ -103,7 +112,9 @@ export class NativeScriptPlatformRef extends PlatformRef { | |
moduleType: Type<M>, | ||
compilerOptions: CompilerOptions | CompilerOptions[] = [] | ||
): Promise<NgModuleRef<M>> { | ||
this._bootstrapper = () => this.platform.bootstrapModule(moduleType, compilerOptions); | ||
this._bootstrapper = () => this.platform.bootstrapModule( | ||
this.appOptions.hmr ? <Type<M>>this.appOptions.hmr.moduleTypeFactory() : moduleType, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That:
can be moved to a variable for readability. |
||
compilerOptions); | ||
|
||
this.bootstrapApp(); | ||
|
||
|
@@ -113,7 +124,11 @@ export class NativeScriptPlatformRef extends PlatformRef { | |
@profile | ||
private bootstrapApp() { | ||
(<any>global).__onLiveSyncCore = () => { | ||
this._livesync(); | ||
if (this.appOptions.hmr) { | ||
this.appOptions.hmr.livesyncCallback(() => this._livesync()); | ||
} else { | ||
this._livesync(); | ||
} | ||
}; | ||
|
||
if (this.appOptions && typeof this.appOptions.cssFile === "string") { | ||
|
@@ -224,7 +239,12 @@ export class NativeScriptPlatformRef extends PlatformRef { | |
if (isLogEnabled()) { | ||
bootstrapLog("Angular livesync started."); | ||
} | ||
onBeforeLivesync.next(lastBootstrappedModule ? lastBootstrappedModule.get() : null); | ||
|
||
const lastModuleRef = lastBootstrappedModule ? lastBootstrappedModule.get() : null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing semicolon |
||
onBeforeLivesync.next(lastModuleRef); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to emit if there's no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There will be no |
||
if (lastModuleRef) { | ||
lastModuleRef.destroy(); | ||
} | ||
|
||
const autoCreateFrame = !!this.appOptions.createFrameOnBootstrap; | ||
let tempAppHostView: AppHostView; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bootstrapPlatfrom -> bootstrapPlatform