CN117931184A - Compose host life cycle sensing method, compose host life cycle sensing device, medium and equipment - Google Patents

Compose host life cycle sensing method, compose host life cycle sensing device, medium and equipment Download PDF

Info

Publication number
CN117931184A
CN117931184A CN202410105553.7A CN202410105553A CN117931184A CN 117931184 A CN117931184 A CN 117931184A CN 202410105553 A CN202410105553 A CN 202410105553A CN 117931184 A CN117931184 A CN 117931184A
Authority
CN
China
Prior art keywords
compose
lifecycle
root node
host
life cycle
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410105553.7A
Other languages
Chinese (zh)
Inventor
邹铭杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Netease Zaigu Technology Co Ltd
Original Assignee
Hangzhou Netease Zaigu Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Netease Zaigu Technology Co Ltd filed Critical Hangzhou Netease Zaigu Technology Co Ltd
Priority to CN202410105553.7A priority Critical patent/CN117931184A/en
Publication of CN117931184A publication Critical patent/CN117931184A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Quality & Reliability (AREA)
  • Human Computer Interaction (AREA)
  • Stored Programmes (AREA)

Abstract

Embodiments of the present disclosure provide a method, apparatus, medium, and device for sensing Compose a host lifecycle, compose a host for hosting a Compose UI interface, compose UI interface comprising a plurality of Compose components, the method comprising: acquiring Compose life cycle objects of a host; saving the lifecycle object in a root node of the Compose view tree; compose the view tree is built based on nested relationships between several Compose components; the lifecycle object is obtained from the root node, and a snoop event for the lifecycle object is registered in Compose component to perceive the lifecycle of the Compose host. The method can enable Compose components to sense the life cycle of Compose hosts, compose components can respond and process timely when the life cycle of Compose hosts changes, performance and stability of application programs are improved, the situation that application resources are repeatedly acquired and repeatedly released can be avoided, and efficiency and accuracy of application resource management are improved.

Description

Compose host life cycle sensing method, compose host life cycle sensing device, medium and equipment
Technical Field
Embodiments of the present disclosure relate to the field of computer technology, and more particularly, embodiments of the present disclosure relate to a method, apparatus, medium, and device for sensing Compose host lifecycles.
Background
This section is intended to provide a background or context to the embodiments of the disclosure recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
Jetpack Compose is a responsive UI development framework for building user interfaces for android applications. In android applications, compose UI interfaces are typically hosted by Compose hosts (e.g., activity, fragment, etc. components), and Compose hosts provide a container for hosting Compose UI interfaces that can be responsible for launching the root components of Compose UI interfaces and processing interactions with hosts.
In the development process of android applications, in order to enhance user experience and improve application performance, developers need to perform corresponding operations according to the life cycle state of Compose hosts. However, in Compose framework, because of the isolation between Compose component and Compose host, compose component cannot directly sense Compose host life cycle, so Compose component cannot respond and process in time when host life cycle changes, and performance and stability of application program are degraded. In the Compose framework, by a method for indirectly sensing the life cycle of the Compose host aiming at LaunchedEffect and DisposableEffect functions of Compose components, the problem that application resources are repeatedly acquired and repeatedly released exists, and the efficiency and accuracy of application resource management are reduced.
Disclosure of Invention
In view of this, the present disclosure provides a sensing method, device, medium and apparatus for Compose host life cycle to solve the deficiencies in the related art.
In a first aspect of embodiments of the present disclosure, there is provided a method of perception of a Compose host lifecycle, the Compose host being for carrying a Compose UI interface, the Compose UI interface comprising a number of Compose components, the method comprising:
Acquiring a life cycle object of the Compose hosts;
saving the lifecycle object in a root node of a Compose view tree; the Compose view tree is built based on nested relationships between the number Compose of components;
The lifecycle object is obtained from the root node, and a listening event for the lifecycle object is registered in the Compose component to perceive the lifecycle of the Compose host.
Optionally, the Compose host carries Compose UI interface through AndroidComposeView component, and the saving the lifecycle object in the root node of Compose view tree includes:
Saving the lifecycle object in the AndroidComposeView component;
The lifecycle object is obtained from the AndroidComposeView component and saved in the root node of the Compose view tree.
Optionally, the method further comprises: adding a specified identifier to the root node of the Compose view tree;
the acquiring the lifecycle object from the root node includes:
in the Compose component, the root node is looked up from the Compose view tree based on the specified identification, and the lifecycle object saved in the root node is obtained.
Optionally, the method further comprises:
Receiving and storing a user-defined method created by a user aiming at a specified life cycle;
Executing the custom method when the specified life cycle is monitored;
When the Compose component is destroyed, the snoop event is cancelled.
In a second aspect of embodiments of the present disclosure, there is provided a sensing device of Compose host life cycle, the Compose host being configured to carry a Compose UI interface, the Compose UI interface comprising a number of Compose components, the device comprising:
A first obtaining module, configured to obtain a lifecycle object of the Compose host;
A first storage module, configured to store the lifecycle object in a root node of a Compose view tree; the Compose view tree is built based on nested relationships between the number Compose of components;
A second obtaining module, configured to obtain the lifecycle object from the root node;
a snoop registration module for registering snoop events for the lifecycle objects in the Compose component to perceive the lifecycle of the Compose host.
Optionally, the Compose host carries Compose UI interface through AndroidComposeView component, and the first storage module includes:
A first storage sub-module for saving the lifecycle object in the AndroidComposeView component;
a first acquisition sub-module for acquiring the lifecycle object from the AndroidComposeView component;
And the second storage sub-module is used for storing the life cycle object in the root node of the Compose view tree.
Optionally, the method further comprises:
An identifier adding module, configured to add a specified identifier to a root node of the Compose view tree;
the second acquisition module includes:
a root node lookup module for, in the Compose component, looking up the root node from the Compose view tree based on the specified identification;
and the second acquisition sub-module is used for acquiring the life cycle object stored in the root node.
Optionally, the method further comprises:
The method storage module is used for receiving and storing a user-defined method created by a user aiming at a specified life cycle;
the method execution module is used for executing the self-defining method when the specified life cycle is monitored;
and the monitoring cancellation module is used for canceling the monitoring event when the Compose component is destroyed.
In a third aspect of embodiments of the present disclosure, a computer-readable storage medium has stored thereon a computer program which, when executed by a processor, implements a method as described in the first aspect above.
In a fourth aspect of embodiments of the present disclosure, there is provided a computing device comprising:
A processor;
a memory for storing a processor executable program;
wherein the processor is configured to implement the method according to the first aspect by running the executable program.
According to the embodiment of the disclosure, the life cycle object of the Compose host is obtained, the life cycle object is stored in the root node of the Compose view tree, the life cycle object is obtained from the root node, and the monitoring event aiming at the life cycle object is registered in the Compose component, so that the Compose component can perceive the life cycle of the Compose host, the Compose component can respond and process in time when the life cycle of the Compose host changes, the performance and stability of an application program are improved, the situation that application resources are repeatedly obtained and repeatedly released can be avoided, and the efficiency and accuracy of application resource management are improved.
Drawings
The above, as well as additional purposes, features, and advantages of exemplary embodiments of the present disclosure will become readily apparent from the following detailed description when read in conjunction with the accompanying drawings. Several embodiments of the present disclosure are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings, in which:
FIG. 1 schematically illustrates a flow chart of a method of sensing Compose a host lifecycle, according to an embodiment of the present disclosure;
FIG. 2 schematically illustrates a block diagram of a Compose host lifecycle awareness apparatus, according to an embodiment of the present disclosure;
FIG. 3 schematically illustrates a schematic diagram of a computer-readable storage medium according to an embodiment of the present disclosure;
fig. 4 schematically illustrates a schematic diagram of a computing device according to an embodiment of the disclosure.
In the drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
Detailed Description
The principles and spirit of the present disclosure will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are presented merely to enable one skilled in the art to better understand and practice the present disclosure and are not intended to limit the scope of the present disclosure in any way. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Those skilled in the art will appreciate that embodiments of the present disclosure may be implemented as a system, apparatus, device, method, or computer program product. Accordingly, the present disclosure may be embodied in the following forms, namely: complete hardware, complete software (including firmware, resident software, micro-code, etc.), or a combination of hardware and software.
According to an embodiment of the disclosure, a sensing method, a device, a medium and equipment for Compose host life cycles are provided.
In this document, it should be understood that any number of elements in the drawings is for illustration and not limitation, and that any naming is used only for distinction and not for any limitation.
The principles and spirit of the present disclosure are explained in detail below with reference to several representative embodiments thereof.
Summary of The Invention
Jetpack Compose is a responsive UI development framework for building user interfaces for android applications. The method adopts a declarative UI programming model, simplifies development flow and improves development efficiency by defining and combining interface elements in a function form, provides rich built-in components and patterns, is convenient for a developer to quickly construct common interface elements, supports responsive programming, and realizes dynamic updating of interfaces and responding to user operation through binding and interaction with data.
In an android application, the Compose UI interface is typically carried by a Compose host (e.g., activity, fragment, etc. component), and the Compose host provides a container for carrying the Compose UI interface that can be responsible for launching the root component of the Compose UI interface and for handling interactions with the host (e.g., handling data communicated by the host, handling user events, etc.).
In the development process of android applications, in order to enhance user experience and improve application performance, developers need to perform corresponding operations according to the life cycle state of Compose hosts. For example, when an application enters the background or loses focus, it is necessary to suspend an ongoing network request or release some resources to improve the performance of the application and save the user's mobile phone power; for another example, when an application returns to the foreground from the background, it is necessary to reload data or reinitialize some components to ensure that the user can obtain the latest data when the application is switched, thereby improving the user experience.
However, the inventors found that in the Compose framework, the Compose component cannot directly perceive the life cycle of the Compose host due to the isolation between the Compose component and the Compose host, so that the Compose component cannot respond and process in time when the host life cycle changes, and the performance and stability of the application are degraded. The inventors have also found that in the Compose framework, both lifecycles of creation and destruction of Compose components can be perceived through LaunchedEffect and DisposableEffect functions. However, when the two functions are recombined (the process of recalculating and drawing the UI interface when the component state or the parameter changes) in the Compose component, and the frequency of the recombination of the Compose component is higher, if the lifecycle of the Compose host is to be indirectly perceived through the lifecycle perception method of the Compose component, the methods which are to be executed when the Compose host is created and destroyed are executed in the two functions, for example, the application resource is acquired when the Compose host is created and released when the application resource is destroyed, which can cause the repeated acquisition and repeated release of the application resource, resulting in resource waste and reduced efficiency and accuracy of application resource management.
Therefore, the inventor proposes a method for perceiving the lifecycle of Compose hosts, by acquiring the lifecycle object of Compose hosts, storing the lifecycle object in the root node of Compose view tree, acquiring the lifecycle object from the root node, and registering a listening event for the lifecycle object in Compose components, so that Compose components can perceive the lifecycle of Compose hosts, compose components can respond and process in time when the lifecycle of Compose hosts changes, the performance and stability of application programs are improved, the situation that application resources are repeatedly acquired and repeatedly released can be avoided, and the efficiency and accuracy of application resource management are improved.
Having described the basic principles of the present disclosure, various non-limiting embodiments of the present disclosure are specifically described below.
Exemplary method
A method of sensing Compose a host lifecycle according to an exemplary embodiment of the present disclosure is described below with reference to fig. 1.
Fig. 1 schematically illustrates a method of perception of a Compose host lifecycle, the Compose host for carrying a Compose UI interface, the Compose UI interface including a number of Compose components, according to an embodiment of the disclosure, the method comprising:
Step S101, acquiring a life cycle object of the Compose host.
Step S102, storing the life cycle object in a root node of Compose view tree; the Compose view tree is built based on nested relationships between the number Compose of components.
Step S103, obtaining the lifecycle object from the root node.
Step S104, registering a listening event for the lifecycle object in the Compose component to perceive the lifecycle of the Compose host.
In this embodiment, compose hosts may include Activity, fragment or the like android components that can be used to host Compose UI interfaces, which is not limiting of the present disclosure.
In this embodiment, compose hosts may be used to construct a UI interface of the android application, for example, the android UI interface may include a plurality of pages, each page may be carried by Activity, a plurality of sub pages may be included in a page, and each sub page may be carried by Fragment. The android UI interface may include a plurality of android components, and an android view tree may be constructed based on a nested relationship between the plurality of android components, and when the android component serving as Compose host carries the Compose UI interface, a Compose component may be nested, or an android component nesting Compose component serving as Compose host sub-component may be nested. In an android application program, compose hosts with specific marks, such as r.id. view_tree_ lifecycle _wner, can recursively search up on child nodes of an android view tree until a node with the specific marks is found, corresponding android components can be Compose hosts of Compose components nested by the child nodes, and life cycle objects (lifecycleowner) of the node can be obtained as life cycle objects of Compose hosts.
In this embodiment, snoop events for lifecycle objects acquired from the root node may be registered at Compose component creation time. Specifically, the creation process of the Compose component may be intercepted by a LaunchedEffect or DisposableEffect function, at this time, a monitor for a lifecycle object may be added by a lifetime. Addo bserver method, a monitor event for the lifecycle object may be registered, the monitor event may monitor several lifecycles of the Compose host, and the lifecycle may include creation, start, display, hiding, suspension, destruction, and the like, which is not limited in this disclosure.
According to the embodiment, the life cycle object of the Compose host is obtained, the life cycle object is stored in the root node of the Compose view tree, the life cycle object is obtained from the root node, and the monitoring event aiming at the life cycle object is registered in the Compose component, so that the Compose component can sense the life cycle of the Compose host, the Compose component can respond and process in time when the life cycle of the Compose host changes, the performance and stability of an application program are improved, the situation that application resources are repeatedly obtained and repeatedly released can be avoided, and the efficiency and the accuracy of application resource management are improved.
The inventor further found that Compose hosts carried Compose UI interface, and when Compose components were added, androidComposeView components were created, and that Compose components were nested by AndroidComposeView components, so the inventor thought that the lifecycle object of Compose hosts could be saved in AndroidComposeView components, and then obtained from AndroidComposeView components, and saved in the root node of Compose view tree.
In one embodiment, compose hosts may carry Compose UI interfaces through AndroidComposeView components. The step of saving the lifecycle object in the root node of the Compose view tree in step S102 may include:
Save lifecycle objects in AndroidComposeView components;
the lifecycle object is obtained from the AndroidComposeView component and saved in the root node of the Compose view tree.
In this embodiment, the creation process of AndroidComposeView components may be intercepted and the acquired life cycle object of the Compose host is saved in AndroidComposeView components at AndroidComposeView component creation.
Specifically, by using the mechanism of CompositionLocal for transferring and sharing data in the Compose view tree, the lifecycle object is saved in the AndroidComposeView component by using the CompositionLocalProvider method, a corresponding custom name can be set for the lifecycle object, and the current method can be called by the root node of the Compose view tree based on the custom name to obtain and save the lifecycle object.
In one embodiment, the Compose host lifecycle awareness method may further include:
Step S105, adding a specified identifier for the root node of Compose view tree;
The step of acquiring the lifecycle object from the root node in step S103 may include:
In the Compose component, the root node is looked up from the Compose view tree based on the specified identification, and the lifecycle object saved in the root node is obtained.
In this embodiment, when the lifecycle object is saved in the root node of the Compose view tree, a specified identifier may be added to the root node of the Compose view tree, so that the Compose component corresponding to the offspring node may determine, according to the specified identifier, the root node in which the lifecycle object is saved.
In this embodiment, the Compose component may recursively look up from the node to which the current Compose component corresponds in the Compose view tree based on the specified identification until a node with the specified identification is found, which is determined to be the root node of the Compose view tree. Specifically, a specified identifier can be introduced as a parameter by the Compositionlocal. GetValueOf method to determine Compose the root node of the view tree.
In one embodiment, the Compose host lifecycle awareness method may further include:
step S106, receiving and storing a user-defined method created by a user aiming at a specified life cycle;
step S107, when a specified life cycle is monitored, a self-defining method is executed;
in step S108, when Compose components are destroyed, the snoop event is cancelled.
In this embodiment, the custom method created by the user for the specified life cycle may be saved by a custom variable, and considering that the user may modify the custom method, the custom method may also be saved by a rememberUpdatedState function, so as to ensure that the latest custom method is obtained, which is not limited in this disclosure.
In this embodiment, previously registered snoop events for lifecycle objects acquired from the root node may be canceled when the Compose components are destroyed. Specifically, the destruction process of the Compose component may be intercepted by the onDispose method of DisposableEffect, and at this time, the listening event for the lifecycle object may be canceled by the lifetime.
The embodiment saves the custom method created by the user aiming at the specified life cycle, so that the user only needs to provide the custom method which is wanted to be executed in the specified life cycle of Compose hosts, the custom method can be executed when the specified life cycle is monitored without other operations, great convenience is provided for the user, and the embodiment can prevent memory leakage and waste of application resources by canceling the monitoring event when the Compose component is destroyed.
Exemplary apparatus
Having introduced a method of an exemplary embodiment of the present disclosure, next, a Compose host life cycle sensing device according to an exemplary embodiment of the present disclosure is described with reference to fig. 2.
Fig. 2 schematically illustrates a Compose host life cycle sensing device according to an embodiment of the present disclosure, the Compose host configured to carry a Compose UI interface, the Compose UI interface including a number Compose of components, the device comprising:
a first obtaining module 11, configured to obtain a lifecycle object of the Compose hosts;
A first storage module 12, configured to store the lifecycle object in a root node of a Compose view tree; the Compose view tree is built based on nested relationships between the number Compose of components;
a second obtaining module 13, configured to obtain the lifecycle object from the root node;
A snoop registration module 14 for registering snoop events for the lifecycle objects in the Compose component to perceive the lifecycle of the Compose host.
In one embodiment, compose hosts may carry Compose UI interfaces through AndroidComposeView components, and the first storage module 12 may include:
A first storage sub-module 110 that may be used to save lifecycle objects in AndroidComposeView components;
a first acquisition sub-module 111, which may be used to acquire lifecycle objects from AndroidComposeView components;
A second storage sub-module 112 may be used to save the lifecycle object in the root node of the Compose-view tree.
In one embodiment, the sensing device of Compose host life cycle may further include:
The identifier adding module 15 may be configured to add a specified identifier to the root node of the Compose view tree;
The second acquisition module 13 may include:
a root node lookup module 130, which may be used to lookup a root node from the Compose view tree based on the specified identification in the Compose component;
the second obtaining sub-module 131 may be configured to obtain the lifecycle object stored in the root node.
In one embodiment, the sensing device of Compose host life cycle may further include:
A method storage module 16 operable to receive and store custom methods created by a user for a specified lifecycle;
The method execution module 17 may be configured to execute a custom method when a specified life cycle is monitored;
The snoop kill module 18 may be used to kill snoop events when Compose components are destroyed.
Exemplary Medium
Having introduced the method of the exemplary embodiments of the present disclosure, next, a computer-readable storage medium of the exemplary embodiments of the present disclosure is described with reference to fig. 3.
In the present exemplary embodiment, the above-described method may be implemented by a program product, such as a portable compact disc read only memory (CD-ROM) and including program code, and may be run on a device, such as a personal computer. However, the program product of the present disclosure is not limited thereto, and in this document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium.
The readable storage medium can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium would include the following: an electrical connection having one or more wires, a portable disk, a hard disk, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave with readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RE, etc., or any suitable combination of the foregoing.
Program code for carrying out operations of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the C programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., connected via the Internet using an Internet service provider).
Exemplary computing device
Having introduced the plug-ins, methods, and media of the exemplary embodiments of the present disclosure, next, a computing device of the exemplary embodiments of the present disclosure is described with reference to fig. 4.
The computing device 40 shown in fig. 4 is merely an example and should not be taken as limiting the functionality and scope of use of embodiments of the present disclosure.
As shown in fig. 4, computing device 40 is in the form of a general purpose computing device. Components of computing device 40 may include, but are not limited to: the at least one processing unit 401, the at least one memory unit 402, and a bus 403 connecting the different system components (including the processing unit 401 and the memory unit 402).
The bus 403 includes a data bus, a control bus, and an address bus.
The storage unit 402 may include readable media in the form of volatile memory, such as Random Access Memory (RAM) 4021 and/or cache memory 4022, and may further include readable media in the form of nonvolatile memory, such as Read Only Memory (ROM) 4023.
The storage unit 402 may also include a program/utility 4025 having a set (at least one) of program modules 4024, such program modules 4024 include, but are not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment.
Computing device 40 may also communicate with one or more external devices 404 (e.g., keyboard, pointing device, etc.).
Such communication may occur through an input/output (I/O) interface 405. Moreover, computing device 40 may also communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet, through network adapter 406. As shown in fig. 4, network adapter 406 communicates with other modules of computing device 40 over bus 403. It should be appreciated that although not shown in the figures, other hardware and/or software modules may be used in connection with computing device 40, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
It should be noted that although in the above detailed description a number of units/modules or sub-units/modules of Compose host life-cycle aware devices are mentioned, this division is only exemplary and not mandatory. Indeed, the features and functionality of two or more units/modules described above may be embodied in one unit/module in accordance with embodiments of the present disclosure. Conversely, the features and functions of one unit/module described above may be further divided into ones that are embodied by a plurality of units/modules.
Furthermore, although the operations of the methods of the present disclosure are depicted in the drawings in a particular order, this is not required or suggested that these operations must be performed in this particular order or that all of the illustrated operations must be performed in order to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step to perform, and/or one step decomposed into multiple steps to perform.
While the spirit and principles of the present disclosure have been described with reference to several particular embodiments, it is to be understood that this disclosure is not limited to the particular embodiments disclosed nor does it imply that features in these aspects are not to be combined to benefit from this division, which is done for convenience of description only. The disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.

Claims (10)

1. A method of perception of Compose host lifecycles, the Compose host being configured to carry a Compose UI interface, the Compose UI interface comprising a plurality of Compose components, the method comprising:
Acquiring a life cycle object of the Compose hosts;
saving the lifecycle object in a root node of a Compose view tree; the Compose view tree is built based on nested relationships between the number Compose of components;
The lifecycle object is obtained from the root node, and a listening event for the lifecycle object is registered in the Compose component to perceive the lifecycle of the Compose host.
2. The method of claim 1, wherein the Compose host hosts Compose UI interfaces through AndroidComposeView components, the saving the lifecycle object in a root node of Compose view tree comprising:
Saving the lifecycle object in the AndroidComposeView component;
The lifecycle object is obtained from the AndroidComposeView component and saved in the root node of the Compose view tree.
3. The method as recited in claim 1, further comprising: adding a specified identifier to the root node of the Compose view tree;
the acquiring the lifecycle object from the root node includes:
in the Compose component, the root node is looked up from the Compose view tree based on the specified identification, and the lifecycle object saved in the root node is obtained.
4. The method as recited in claim 1, further comprising:
Receiving and storing a user-defined method created by a user aiming at a specified life cycle;
Executing the custom method when the specified life cycle is monitored;
When the Compose component is destroyed, the snoop event is cancelled.
5. A sensing device for a Compose host life cycle, the Compose host for carrying a Compose UI interface, the Compose UI interface comprising a plurality of Compose components, the device comprising:
A first obtaining module, configured to obtain a lifecycle object of the Compose host;
A first storage module, configured to store the lifecycle object in a root node of a Compose view tree; the Compose view tree is built based on nested relationships between the number Compose of components;
A second obtaining module, configured to obtain the lifecycle object from the root node;
a snoop registration module for registering snoop events for the lifecycle objects in the Compose component to perceive the lifecycle of the Compose host.
6. The apparatus of claim 5, wherein the Compose host hosts a Compose UI interface through a AndroidComposeView component, the first storage module comprising:
A first storage sub-module for saving the lifecycle object in the AndroidComposeView component;
a first acquisition sub-module for acquiring the lifecycle object from the AndroidComposeView component;
And the second storage sub-module is used for storing the life cycle object in the root node of the Compose view tree.
7. The apparatus as recited in claim 5, further comprising:
An identifier adding module, configured to add a specified identifier to a root node of the Compose view tree;
the second acquisition module includes:
a root node lookup module for, in the Compose component, looking up the root node from the Compose view tree based on the specified identification;
and the second acquisition sub-module is used for acquiring the life cycle object stored in the root node.
8. The apparatus as recited in claim 5, further comprising:
The method storage module is used for receiving and storing a user-defined method created by a user aiming at a specified life cycle;
the method execution module is used for executing the self-defining method when the specified life cycle is monitored;
and the monitoring cancellation module is used for canceling the monitoring event when the Compose component is destroyed.
9. A computer readable storage medium, characterized in that a computer program is stored thereon, which computer program, when being executed by a processor, implements the method according to any of claims 1-4.
10. A computing device, comprising:
A processor;
a memory for storing a processor executable program;
wherein the processor is configured to implement the method of any of claims 1-4 by running the executable program.
CN202410105553.7A 2024-01-24 2024-01-24 Compose host life cycle sensing method, compose host life cycle sensing device, medium and equipment Pending CN117931184A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410105553.7A CN117931184A (en) 2024-01-24 2024-01-24 Compose host life cycle sensing method, compose host life cycle sensing device, medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410105553.7A CN117931184A (en) 2024-01-24 2024-01-24 Compose host life cycle sensing method, compose host life cycle sensing device, medium and equipment

Publications (1)

Publication Number Publication Date
CN117931184A true CN117931184A (en) 2024-04-26

Family

ID=90768124

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410105553.7A Pending CN117931184A (en) 2024-01-24 2024-01-24 Compose host life cycle sensing method, compose host life cycle sensing device, medium and equipment

Country Status (1)

Country Link
CN (1) CN117931184A (en)

Similar Documents

Publication Publication Date Title
CN110413288B (en) Application deployment method, device, server and storage medium
US9852015B2 (en) Automatic discovery of a JavaScript API
CA2604827C (en) Method for handling a detected error in a script-based application
CN109445841B (en) Interface document management method, device, server and storage medium
US20180239681A1 (en) Widget Provisioning of User Experience Analytics and User Interface / Application Management
CN112199567A (en) Distributed data acquisition method, system, server and storage medium
CN112230857B (en) Hybrid cloud system, hybrid cloud disk application method and data storage method
CN113778445A (en) Cross-platform component generation method and device, electronic equipment and storage medium
CN110188308B (en) Client automatic dotting reporting method, storage medium, equipment and system
CN116755788A (en) On-line rule modification method, device, equipment and storage medium
CN112769706A (en) Componentized routing method and system
US10185647B2 (en) Debugging remote vertex code on test machine
CN114371914A (en) Container IP address configuration method and device, storage medium and electronic equipment
US11200052B1 (en) Documentation enforcement during compilation
CN114816445A (en) System platform architecture, function publishing method and device, platform and storage medium
CN111352644A (en) Applet updating method, device, server and storage medium
CN116578282A (en) Code generation method, device, electronic equipment and medium
CN117931184A (en) Compose host life cycle sensing method, compose host life cycle sensing device, medium and equipment
CN113448585B (en) Compiling method and device of thread pool, electronic equipment and storage medium
CN110599112A (en) Method and device for developing and maintaining network page
CN113986879A (en) Service data migration method and related device
CN114116030A (en) Operating system running method and device, electronic equipment and storage medium
CN113110846A (en) Method and device for acquiring environment variable
CN108089852B (en) Method, medium, apparatus and computing device for establishing attribute access
CN112148935A (en) Method and apparatus for NBMP function execution for multiple instances

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination