Background: After the completion of CR of Fuhong Hanlin project. To sort out the areas that need to be optimized and send messages to other pages.

Optimize project startup time

Let’s remember how long it took to initially run:



Time to run after deleting 99% of console.log and resolving all TSLint errors:

That’s 14.78s less. Really, don’t look down on console.log…

Send a message

Real development scenario: The information of the current log-in is saved on the main page. At the beginning of the login into the home page when stored, and then other pages used personnel information is the home page out. In one of the modules after the modification of personnel positions. The main page did not retrieve personnel information. This will result in incorrect information for other modules. Solution: in one of the modules to modify the staff post, to the main page to send a message. Tell it that it needs to retrieve the login information. (Any other page can retrieve this message through Events.)

Import {Events} from 'ionic-angular'; export class SetupPage { constructor(public ev: Events) {} / switch/post chooseJob = () = > {the if (this. TerritoryList. Length < = 1) {return; } let modal = this.modalCtrl.create("ChooseJobPage", { jobList:this.territoryList ,territoryID},{ cssClass: 'inset-modal'}); Modal.ondiddismiss (data => {if (data.action == 'save') {// Tell the main page to retrieve the personnel information // after the job switch is successful Use this. Ev. The publish (' selectedStff) message. Enclosing staffService. SelectedTerritoryToken (json). Then ((info) = > {this.ev.publish('selectedStff')})} }); modal.present(); }}
// import {Events} from 'ionic-angular'; export class MyApp { constructor(public ev: Subscribe (" selectedStaffInfo ", () =>{this.getStaffInfo(); })} / / for the current user information getStaffInfo = () = > enclosing staffService. GetStaffInfo (). Then ((info) = > {/ / to assign personnel information enclosing currentStaff = info; }); }