This repository has been archived by the owner on Aug 7, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Angular): apply changes in application styles at runtime with HMR (
#748) * feat(Angular): apply changes in application styles at runtime with HMR * refactor(HMR): unify snippet for different flavors `global.__hmrInitialSync` is no more used `global.__hmrNeedReload` is removed: - on changes in multiple files (app.css, main-page.css, main-page.xml, main-page.ts) both *reapply styles* and *navigate* logic need to execute - this is important for the bootstrap of Angular apps * refactor(HMR): unify snippet for different flavors Remove `hmrUpdate()` from `main.ts` as a duplication of `global.__onLiveSync()`. `global.__onLiveSync()` ensures all patches get to the bundle. * fix(HMR): initial updates on app restart
- Loading branch information
Showing
6 changed files
with
71 additions
and
46 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,10 +1,26 @@ | ||
// this import should be first in order to load some required settings (like globals and reflect-metadata) | ||
import { platformNativeScriptDynamic } from "nativescript-angular/platform"; | ||
import { AppOptions } from "nativescript-angular/platform-common"; | ||
|
||
import { AppModule } from "./app.module"; | ||
|
||
let options: AppOptions = {}; | ||
|
||
if (module["hot"]) { | ||
options.hmrOptions = { | ||
moduleTypeFactory: () => AppModule, | ||
livesyncCallback: (platformReboot) => { | ||
setTimeout(platformReboot, 0); | ||
}, | ||
} | ||
|
||
// Path to your app module. | ||
// You might have to change it if your module is in a different place. | ||
module["hot"].accept(["./app.module"], global["__hmrRefresh"]); | ||
} | ||
|
||
// A traditional NativeScript application starts by initializing global objects, setting up global CSS rules, creating, and navigating to the main page. | ||
// Angular applications need to take care of their own initialization: modules, components, directives, routes, DI providers. | ||
// A NativeScript Angular app needs to make both paradigms work together, so we provide a wrapper platform object, platformNativeScriptDynamic, | ||
// that sets up a NativeScript application and can bootstrap the Angular framework. | ||
platformNativeScriptDynamic().bootstrapModule(AppModule); | ||
platformNativeScriptDynamic(options).bootstrapModule(AppModule); |
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
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