-
-
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
Conversation
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
missing semicolon
a98c195
to
b35fa39
Compare
|
||
export interface HmrOptions { | ||
moduleTypeFactory?: () => Type<any> | NgModuleFactory<any>; | ||
livesyncCallback: (bootstrapPlatfrom: () => void) => void; |
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
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
hmr -> hmrOptions
I thought hmr
was a boolean at first.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
That:
this.appOptions.hmr ? <Type ...
can be moved to a variable for readability.
onBeforeLivesync.next(lastBootstrappedModule ? lastBootstrappedModule.get() : null); | ||
|
||
const lastModuleRef = lastBootstrappedModule ? lastBootstrappedModule.get() : null; | ||
onBeforeLivesync.next(lastModuleRef); |
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.
Do we need to emit if there's no lastBootstrappedModule
?
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.
There will be no lastBootstrappedModule
if there was an error in the initial bootstrap and lastBootstrappedModule.get()
will return null
if the angular app was manually killed and collected (don't think it is a common practice in NS apps, but still ...). In either case I think the onBeforeLivesync
should emit to be in balance with the onAfterLivesync
.
b8927fe
to
fee8fc6
Compare
Pass `hmr` specific options on application bootstrap. The hmr options are: - `moduleTypeFactory?: () => Type<any> | NgModuleFactory<any>;` A module factory for re-instantiating the bootstrap module or module-factory on livesync. - `livesyncCallback: (bootstrapPlatfrom: () => void) => void;` A `livesync` callback that will be called instead of the original livesync. It gives the `hmr` a hook to apply the module replacement. The callback also accepts `bootstrapPlatfrom` function which triggers bootstrap of the angular app with the existing platform using the `moduleTypeFactory` to get module/module-factory to be used.
Pass
hmr
specific options on application bootstrap. The hmr options are:moduleTypeFactory?: () => Type<any> | NgModuleFactory<any>;
A module factory for re-instantiating the bootstrap module or module-factory on livesync.livesyncCallback: (bootstrapPlatfrom: () => void) => void;
Alivesync
callback that will be called instead of the original livesync. It gives thehmr
a hook to apply the module replacement. The callback also acceptsbootstrapPlatfrom
function which triggers bootstrap of the angular app with the existing platform using themoduleTypeFactory
to get module/module-factory to be used.