Introduction to micro-Letter applet (v)

Source: Internet
Author: User
Tags time interval
24.MINA Frame Explanation

Mina Framework Architecture

25. Small program Operation mechanism

Small program in the first open time will be longer, the subsequent open start will be very fast, then how to start the applet?

Operating mechanism-startup

    • Cold start
    • Hot start

Hot start: The user has opened a small program, and then in a certain period of time to open the applet, this time, do not need to restart, just need to switch the background applet to the foreground to use, this process is called hot start.

Cold start: When the user first opens or the applet is actively destroyed and then opened again, the applet needs to reload the boot. So when did the small program be voluntarily destroyed? There are two kinds of situations.

    • After the applet enters the background, the client will help us maintain a state of the applet for a certain period of time,
      The time is five minutes after the active destruction.

    • When the system alarm is received in a short time, it will actively destroy the small program, this short time interval is 5s.

26. Small program loading mechanism

Operating mechanism-loading

27. Life cycle

The life cycle of a small program is divided into the application life cycle and the page life cycle

Application life cycle

You can see that the applet application life cycle is divided into four hooks: onlaunch,onshow, Onhide and OnError. The first time you enter a small program, the client will help us initialize the operating environment of the applet, download it from the CDN, or get the code package from the local store to the applet, and inject it into the running environment. When the initialization is complete, the client distributes the Onlaunch event to the logic Layer App.js app instance, then the Onlaunch method is called. After entering the small program, the user can click "Close" or the "Home" button on the phone to leave the applet, this time the applet is not directly destroyed, but into the background state. The Onhide method defined in the logic Layer app builder is called. When we open the applet again, the client will wake the background hide applet, and this time the applet will enter the foreground state. The OnShow method inside the app builder is called. The OnError method is triggered when a script error occurs in the applet or when the API fails to enter the program. The GlobalData here represents a global data for the applet application.

Page life cycle

When the page is first loaded, the client gives us an onload event for a configuration instance defined in the logical layer, and the OnLoad method defined by the configuration constructor parameter is called, which is called only once before the page is destroyed. In the onload callback we can get some parameters of the current page. After the page is displayed, the OnShow method defined by the configuration constructor parameter is called. After the first rendering of the page, the Onready method defined by the configuration constructor parameter is called, and after the Onready method is triggered, the logical and view layers can interact. Opens a new page based on the current page, then the Onhide method defined by the configuration constructor parameter is triggered on the current page. If the current page is closed, the OnUnload method is triggered. The data here represents the current page.

Example diagram

The applet consists of two large threads

    • Appservie Thread
    • View Thread

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.