CN115576578A - Component updating method and device, computer readable storage medium and terminal - Google Patents
Component updating method and device, computer readable storage medium and terminal Download PDFInfo
- Publication number
- CN115576578A CN115576578A CN202211058512.4A CN202211058512A CN115576578A CN 115576578 A CN115576578 A CN 115576578A CN 202211058512 A CN202211058512 A CN 202211058512A CN 115576578 A CN115576578 A CN 115576578A
- Authority
- CN
- China
- Prior art keywords
- state data
- component
- calling
- state
- subset
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
A component updating method and device, a computer readable storage medium and a terminal are provided, the method comprises the following steps: determining a state data set of an application program, wherein the state data set is used for storing state data called by each component of the application program; splitting the state data set to obtain state data subsets with preset splitting quantity; determining a subset of state data to be modified; for each subset of state data to be modified, determining one or more calling components of the subset of state data; at least a portion of the determined state data for each calling component is updated. The scheme can reduce the resource overhead of updating the components and improve the updating efficiency of the components.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a component update method and apparatus, a computer-readable storage medium, and a terminal.
Background
The page constructed based on the constructed user interface programming language library React is composed of components one by one. There is a nested relationship between the components, for example a tree of components may be formed, each having respective state data (the state data of a component may be the data required to make the component expose). Relationships between various components of a component tree can be divided into parent and child components, sibling components, and components that have no direct relationship. The component tree has a common parent component, called the root component, which is the source of all components. In a general sense, the read state data stream is uniformly managed by a parent component, placed in the state data of the parent component, and then passed by the props to the child components (or it can be understood that the child components call the state data in the parent component through the props). The method for updating state data in the parent component is also transmitted to the child component through the props. However, in a general business page, the hierarchy of components is very deep, and the transmission of state data across multiple components (the state data can only be transmitted layer by layer between parent and child components) causes a series of problems such as code redundancy, difficulty in debugging, complexity of simple problems and the like. Therefore, it is necessary to research a method of globally managing the state of the page, including updating the state of the component, and the like, in order to reduce complexity.
In the prior art, a relatively common solution is to use a Context Application Program Interface (API) provided by fact to place state data called by all components of an Application program at one place for unified maintenance, for example, a state tree may be used to maintain all calling state data. In particular, react updates the state tree by passing the state tree from the root component and then calling an update API in each sub-component, the update API called in the sub-component being used to update the portion of the state tree that was called by that sub-component.
However, the above method has obvious defects that: all components are updated (i.e., all components are re-rendered) each time any state data in the state tree is updated, even if the updated state data is used by only one or a few components. As a result, many invalid component updates are created, resulting in wasted resource overhead and inefficient component updates. Taking map editing software as an example, a map editing application scene belongs to a scene with high-frequency trigger state updating. If the scheme is adopted, the components in the map editing software can frequently trigger updating. However, the updating of large quantities of components occupies more resources, and the visual effect presented to the user is that the page is very jammed, so that the editing efficiency of editing personnel is greatly reduced, and the smooth development of business is difficult to support.
Disclosure of Invention
The technical problem solved by the embodiment of the invention is that the existing component updating method can trigger a plurality of invalid component updates, thereby causing waste of resource expenditure and reduction of component updating efficiency.
In order to solve the above technical problem, an embodiment of the present invention provides a component update method, including the following steps: determining a state data set of an application program, wherein the state data set is used for storing state data called by each component of the application program; splitting the state data set to obtain state data subsets with preset splitting quantity; determining a subset of state data to be modified; for each subset of state data to be modified, determining one or more calling components of the subset of state data; at least a portion of the determined state data for each calling component is updated.
Optionally, each state data in the state data set has a preset mapping relationship with one or more calling components.
Optionally, the determining the subset of the state data to be modified includes: receiving a state data subset modification instruction, wherein the state data subset modification instruction comprises indication information indicating the state data subset to be modified; and determining the state data subset to be modified according to the received state data subset modification instruction.
Optionally, the updating at least a part of the determined state data of each calling component includes: for each calling component, determining a state updating instruction of the calling component; updating at least a portion of the state data of the calling component according to the determined state update instruction; wherein the state update instruction of each calling component is used for indicating that at least one part of the state data of the calling component is updated.
Optionally, the state update instruction of each calling component is further configured to instruct synchronous update of at least a portion of the state data of the calling component and the state data in the subset of the state data called by the calling component, which is the same as at least a portion of the state data of the calling component.
Optionally, each calling component consumes at least a portion of the state data in the called state data subset based on the state data subset calling instruction; for each calling component, determining the state update instruction of the calling component comprises: a state update instruction for the calling component is determined each time the state data subset consuming instruction for the calling component is executed.
Optionally, the determining, each time the state data subset consuming instruction of the calling component is executed, a state updating instruction of the calling component includes: each time a state data subset consuming instruction in the calling component is executed, a state data calling instruction is created and executed, and then a state updating instruction returned by the state data calling instruction is determined.
Optionally, after determining, for each calling component, a state update instruction of the calling component, the method further includes: adding the determined state update instruction to the state update instruction array.
Optionally, the state data call instruction is a UseState () function provided by a constructed user interface programming language library fact, and the state update instruction returned by the state data call instruction is a SetState () function provided by the fact.
Optionally, the components of the application form a component tree, where the component tree has multiple component layers, each component layer has one or more components, and each sub-component has one or more calling state data called from an affiliated parent component; the method further comprises the following steps: determining a call state data set for each sub-component; caching the current state data of each sub-component; for each sub-component, judging whether the updated state data of the parent component has the state data of the calling state data set of the sub-component or not every time the state data of the parent component to which the sub-component belongs is updated; if the judgment result is yes, updating the calling state data of the sub-component, which is the same as the updated state data, by adopting the updated state data for the updated state data of the calling state data set of the sub-component, and updating other state data of the sub-component by adopting the cache state data of the sub-component.
Optionally, the method further includes: and if not, updating all the state data of the sub-component by using the cached state data.
Optionally, the method further includes: for each sub-component, after the state data of the sub-component is updated each time, the current state data of the component is cached.
Optionally, the method further includes: the current state data of each sub-component is cached periodically.
An embodiment of the present invention further provides a device for updating a component, including: the system comprises a state data set determining module, a state data set determining module and a state data set judging module, wherein the state data set determining module is used for determining a state data set of an application program, and the state data set is used for storing state data called by each component of the application program; the state data set splitting module is used for splitting the state data set to obtain state data subsets with preset splitting quantity; the to-be-modified state data subset determining module is used for determining the to-be-modified state data subset; the calling component determining module is used for determining one or more calling components of each state data subset to be modified; and the component updating module is used for updating at least one part of the determined state data of each calling component.
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of the above component updating method.
The embodiment of the invention also provides a terminal, which comprises a memory and a processor, wherein the memory is stored with a computer program capable of running on the processor, and the processor executes the steps of the component updating method when running the computer program.
Compared with the prior art, the technical scheme of the embodiment of the invention has the following beneficial effects:
in the embodiment of the invention, a state data set of an application program is determined, wherein the state data set is used for storing state data called by each component of the application program; splitting the state data set to obtain state data subsets with preset splitting quantity; determining a subset of state data to be modified; for each subset of state data to be modified, determining one or more calling components of the subset of state data; at least a portion of the determined state data for each calling component is updated.
In the prior art, with the ContextAPI solution provided by act, all state data of all component calls of an application program are put into one unified maintenance, for example, a state tree is imported from a root component to maintain the state data of all component calls. This approach triggers all components of the application to re-render each time there is a state data update in the state tree, resulting in many invalid component updates. Therefore, resource overhead is wasted, the efficiency of updating the components is low, and the page display effect and performance are reduced. Compared with the prior art, the embodiment of the present invention proposes the concept of the atomization state, and obtains a plurality of state data subsets (that is, a plurality of atomic objects Atom) by splitting the set of all state data called by each component of the application program, and introduces Atom to be called inside each component as needed. When determining that an Atom is to be modified/updated, determining each calling component of the subset of state data to be modified, and updating the state of each determined calling component. This allows that only those components that have invoked the subset of state data to be modified are updated, not all components. Therefore, the method is beneficial to greatly improving the page performance, reducing the invalid rendering of the components, reducing the resource overhead and improving the updating efficiency of the components.
Further, after determining, for each calling component, a state update instruction for the calling component, the method further comprises: adding the determined state update instruction to the state update instruction array. In the embodiment of the present invention, for each calling component (each component may be an Object) of the to-be-modified state data subset, the state update instruction of the calling component is collected and stored in the state update instruction array. According to the scheme, after one or more calling components of the state data subset to be modified are determined each time, the state updating instruction of each calling component can be rapidly determined by searching the array, and each calling component is updated. Therefore, the efficiency and stability of component updating are improved.
Further, the method further comprises: determining a call state data set for each sub-component; caching the current state data of each sub-component; for each sub-component, when the state data of a parent component to which the sub-component belongs is updated, judging whether the updated state data of the parent component has the state data existing in the calling state data set of the sub-component; if yes, updating the calling state data in the sub-component, which is the same as the updated state data, by adopting the updated state data for the updated state data of the calling state data set of the sub-component in the parent component, and updating other state data of the sub-component by adopting the cache state data of the sub-component.
In the prior art, a Context related API provided by React is adopted to manage components of a page, and as long as the state of a parent component is changed, all logic in the child component is triggered to be re-executed and re-rendered passively, even if state data updated in the parent component is not called by the child component, great performance and resource loss are brought. Compared with the prior art, the embodiment of the invention adds a cache technology and a mechanism for judging the updated state data in the parent component, updates the same state data of the child component by adopting the updated state data only for the updated state data belonging to the state data called by the child component in the parent component, and directly retrieves the original data from the cache for other state data of the child component to overcome the default change part. Thus, performance loss and resource overhead increase due to redundant logic execution can be avoided.
Drawings
FIG. 1 is a flow chart of a component upgrade method in an embodiment of the present invention;
FIG. 2 is a partial flow diagram of another component update method in an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a component update apparatus according to an embodiment of the present invention.
Detailed Description
As mentioned above, since all components in a business page are deep in hierarchy, the transmission of state data across multiple components causes a series of problems such as redundancy of code, difficulty in debugging, and complication of simple problems. Therefore, there is a need for an improved method for managing and updating the state of page components to reduce complexity.
In the prior art, a common solution to the above problem is to use a Context Programming Interface (API) provided by read to perform component management. The technology puts the state data of all component calls of the application program into a unified maintenance, for example, the state tree can be adopted to maintain the call state data of all the components. Specifically, react is implemented by passing the state tree from the root component and then calling an update API in each sub-component, where the called update API in the sub-component is used to update the portion of the state tree that is called by the sub-component.
The inventor of the present invention has found through research that the above method has the following obvious defects: all components are updated (i.e., all components are re-rendered) each time any state data in the state tree is updated, even if the updated state data is used by only one or a few components. Therefore, a lot of invalid component updates are caused, which causes waste of resource overhead and low efficiency of component update, and further causes the page display effect and performance of the application program to be reduced.
In order to solve the above technical problem, an embodiment of the present invention provides a component updating method, which specifically includes: determining a state data set of an application program, wherein the state data set is used for storing state data called by each component of the application program; splitting the state data set to obtain state data subsets with preset splitting quantity; determining a subset of state data to be modified; for each subset of state data to be modified, determining one or more calling components of the subset of state data; at least a portion of the determined state data for each calling component is updated.
From the above, in the embodiment of the present invention, a concept of an atomization state is proposed, specifically: the method comprises the steps of obtaining a plurality of state data subsets (namely, obtaining a plurality of Atom objects Atom by splitting a set of all state data called by each component of an application program), and introducing Atom to be used as required inside each component. When it is determined that Atom is to be modified/updated, determining each calling component of the subset of state data to be modified, and updating the state of each determined calling component. This allows that only those components that have invoked the subset of state data to be modified are updated, not all components. Therefore, the method is beneficial to greatly improving the page performance, reducing the invalid rendering of the components, reducing the resource overhead and improving the updating efficiency of the components.
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in detail below.
Referring to fig. 1, fig. 1 is a flow chart of a component updating method in an embodiment of the present invention. The method may include steps S11 to S15:
step S11: determining a state data set of an application program, wherein the state data set is used for storing state data called by each component of the application program;
step S12: splitting the state data set to obtain state data subsets with preset splitting quantity;
step S13: determining a subset of state data to be modified;
step S14: for each subset of state data to be modified, determining one or more calling components of the subset of state data;
step S15: at least a portion of the determined state data for each calling component is updated.
In the specific implementation of step S11, the status data of the component of the application may be data required for component presentation. As a non-limiting example, the state data set may be a collection of individual state data in a component state tree of an application. In the page component state management based on the fact frame, the state tree can be adopted to carry out global maintenance on the state data called by each component.
Each state data in the state data set has a preset mapping relation with one or more calling components. In specific implementation, a developer may determine one or more calling components corresponding to each piece of state data according to a function implementation requirement.
Wherein, in the computer programming language, each component of the application program can be an Object (Object). The parameters of the component object may be selected from one or more of data (state data inside the component), tips (default values are set for externally incoming data), onInit (component lifecycle function, triggered at component creation), deriveDataFromProps (component lifecycle function, triggered at component creation and before update), and methods (methods of the component, which may be event response functions or any custom methods). The parameters of the component object may also contain other parameters. The embodiment of the present invention is not limited thereto.
In a specific implementation of step S12, the preset splitting number may be used to split the state data set. The split number may determine an appropriate split number according to a total number of state data in the component state data set, a total number of components of the application, a component update efficiency requirement, a page display effect or performance requirement of the application, and the like. The embodiment of the invention does not limit the specific value of the split number.
The number of the state data in each split state data subset can be the same or different.
In a specific implementation, the state data set may be split according to the type of each state data. The state data set may also be split according to the calling component type, e.g., state data of component calls of similar functions are split to the same subset of state data. The state data set can also be split according to the calling component at the level of the component tree, for example, the state data of the calling component at the same level is split into the same state data subset. The splitting process may also be performed in other manners according to the needs of specific application scenarios, which is not limited in this embodiment of the present invention.
In a specific implementation of step S13, the determining the subset of state data to be modified may include: receiving a state data subset modification instruction, wherein the state data subset modification instruction comprises indication information indicating the state data subset to be modified; and determining the state data subset to be modified according to the received state data subset modification instruction.
In some non-limiting embodiments, a programmer may define state data objects in an application to store state data in various subsets of state data. The state data object may be referred to as an atomic Atom object. Each subset of state data corresponds to an Atom object, for example, splitting a state data set results in n subsets of state data, which correspond to Atom _1 objects, atom _2, atom _3objects, \8230;, atom _ n objects (n is a positive integer, and the number of n is the same as the number of state data subsets), respectively.
When some or all of the status data stored in an Atom object needs to be modified/updated, a programmer may define a SetAtom () function as the status data subset modification instruction, and may use an Atom object to be modified (for example, atom _3 object) as a parameter of SetAtom (), where Atom _3 may be used as indication information of the status data subset to be modified. Each time the SetAtom () function is executed, the subset of state data to be modified may be determined according to indication information of the subset of state data to be modified in the executed SetAtom () function.
In a specific implementation of step S14, after obtaining the respective state data subsets through the splitting process of step S13, for each state data subset, each state data in the subset corresponds to (or is called by) one or more calling components. Thus, all calling components for each subset of state data may be determined.
As a non-limiting embodiment, a state data set is split to obtain 4 state data subsets, where the 4 state data subsets correspond to an Atom _1 object, an Atom _2 object, an Atom _3 object, and an Atom _4 object, respectively. Taking Atom _1 as an example, the object stores four state data of a, B, C, and D, the calling components of a are A1 and A2, and the calling components of B1 are A1, B2, and C3 are A2 and D1. From the above, the set of calling components of the state data subset corresponding to Atom _1 object can be determined to be { A1, A2, B1, B2, C3, D1}. It should be noted that the names in the above embodiments are only exemplary names, and do not constitute a limitation on the actual names of the components, state data, and state data subsets in the actual application.
In the implementation of step S15, since the state data of each component may be data required for displaying the component, after at least a part of the determined state data of each calling component is updated, each calling component will re-render, which may specifically represent a change in page display effect.
Further, the step S15 may include: for each calling component, determining a state updating instruction of the calling component; updating at least a portion of the state data of the calling component according to the determined state update instruction; wherein the state update instruction of each calling component is used for indicating that at least one part of the state data of the calling component is updated.
Further, each calling component consumes at least a portion of the state data in the called subset of state data based on the subset of state data calling instruction; for each calling component, determining the state update instruction of the calling component comprises: a state update instruction for the calling component is determined each time the state data subset consuming instruction for the calling component is executed.
Further, determining the state update instruction for the calling component each time the state data subset consuming instruction for the calling component is executed comprises: each time a state data subset consuming instruction in the calling component is executed, a state data calling instruction is created and executed, and then a state updating instruction returned by the state data calling instruction is determined.
In some non-limiting embodiments, the state data call instruction is a UseState () function provided by the build user interface programming language library React, and the state update instruction returned by the state data call instruction is a SetState () function provided by the React.
In connection with the embodiment provided by step S13 of FIG. 1, a programmer may define n Atom objects Atom _1, atom _2, atom _3, 8230; \8230;, atom _ n objects in an application to store state data in respective subsets of state data, respectively (n is a positive integer and n has the same value as the number of state data subsets).
The programmer may then define state data subset consumption instructions in one or more components, such as defining a UseAtom () function in calling component a, the argument of which is an Atom object (e.g., atom _3 object) called by the current component a.
Also, the usestat () function provided by read may be called inside the UseAtom () function, and the execution result of the usestat () function may return two arguments, one being the current value of at least a portion of the state data consumed/called by the called component a in the Atom _3 object, and the other being a state update instruction (e.g., setStat ()), which may be used to indicate an update of at least a portion of the state data in the called component a.
Finally, when the state data of the calling component A is updated, the calling component A is also updated/re-rendered.
When at least a part of state data in the calling component A is updated, the same state data in the subset of the state data (corresponding to Atom _3 object) called by the calling component A as the updated at least a part of state data is also updated synchronously.
Further, after determining, for each calling component, a state update instruction for the calling component, the method further comprises: adding the determined state update instruction to the state update instruction array. It is understood that by collecting and storing the determined state update instructions of the respective calling components in an array, after determining one or more calling components of the state data subset to be modified each time, the array can be searched to quickly determine the state update instructions of the respective calling components and update the respective calling components. Therefore, the efficiency and the stability of updating the components are improved.
In the embodiment of the present invention, a set of all state data called by each component of an application program is split to obtain a plurality of state data subsets (that is, a plurality of Atom objects Atom are obtained by splitting), and Atom needed to be used is introduced into each component as needed. When determining that an Atom is to be modified/updated, determining each calling component of the subset of state data to be modified, and updating the state of each determined calling component. With this approach, it is possible to update only those components of the subset of state data to be modified, rather than all components. Therefore, the method is beneficial to greatly improving the page performance, reducing the invalid rendering of the component, reducing the resource overhead and improving the updating efficiency of the component.
Referring to fig. 2, fig. 2 is a partial flowchart of another component updating method in an embodiment of the present invention.
In this embodiment, the components of the application may form a component tree, which may have multiple component levels, each component level having one or more components, each sub-component having one or more call state data called from an affiliated parent component. Another component updating method described in this embodiment may include steps S11 to S15 shown in fig. 1, and further include steps S21 to S26.
The step S21 and the step S22 may not be executed sequentially, and the steps S21 to S22 and the steps S11 to S14 may not be executed sequentially. The following description is made of differences from fig. 1.
In step S21, a call state data set of each sub-component is determined.
Wherein the calling state data set comprises one or more calling state data called by the sub-component from the affiliated parent component. In particular implementations, a dependency array may be employed to store the call state data set for each subcomponent.
In step S22, for each sub-component, the current state data of the sub-component is cached.
In step S23, it is confirmed that the status data of the parent component to which the child component is subordinate is updated.
In step S24, it is determined whether or not there is any status data existing in the call status data set of the child component among the updated pieces of status data of the parent component.
If it is confirmed that there is state data existing in the call state data set of the child component among the updated respective state data of the parent component, the execution proceeds to step S25. If it is confirmed that the updated respective state data of the parent component does not have the state data of the calling state data set of the child component, execution proceeds to step S26.
In step S25, for the updated status data of the calling status data set existing in the sub-component, the calling status data of the sub-component, which is the same as the updated status data, is updated with the updated status data, and the other status data of the sub-component is updated with the cached status data of the sub-component.
In step S26, all the status data of the sub-component is updated with the cached status data.
As a non-limiting example, for a sub-component M, the parent component to which the sub-component belongs is N, where the state data within parent component N is { a, b, d, e, f, g } and the state data within sub-component M is { M, e, f, g, p, q }.
In the above embodiment, it is determined that M calls each call state data from N to form a call state data set { e, f, g }, and current state data { M, e, f, g, p, q } of the subcomponent M is cached.
Every time the state data in the parent component N is updated (e.g., f is updated to f 1), it is determined whether f exists in the call state data set { e, f, g }. If it is confirmed that f exists in { e, f, g }, then f in the sub-component M is updated with the updated data f1 of f, and the other state data { M, e, g, p, q } in the sub-component except f is updated with the cached state data of the sub-component.
Further, the another component updating method further includes: for each sub-component, caching the current state data of the component after updating the state data of the sub-component each time.
In the embodiment of the invention, by adding a cache mechanism and a mechanism for judging the updated state data in the parent component, the updated state data is adopted to update the same state data of the child component only for the updated state data in the parent component, which belongs to the state data called by the child component. The other state data for the sub-component is then retrieved directly from the cache as the original data to overcome that portion of the default change. Therefore, the problem that in the prior art, when the content related API provided by React is adopted to manage the components of the page, as long as the state of the parent component is changed, all logic inside the child component is triggered to be re-executed and passively re-rendered (even if updated state data in the parent component is not called by the child component) is solved, and performance loss and resource overhead increase caused by redundant logic execution can be avoided.
In a specific implementation, please refer to the foregoing description and the step description in fig. 1 for further details regarding the another component updating method, which are not described herein again.
Referring to fig. 3, fig. 3 is a schematic structural diagram of a component update apparatus according to an embodiment of the present invention. The component update apparatus may include:
a state data set determining module 31, configured to determine a state data set of an application, where the state data set is used to store state data called by each component of the application;
a state data set splitting module 32, configured to split the state data set to obtain state data subsets with a preset splitting number;
a to-be-modified state data subset determining module 33, configured to determine a to-be-modified state data subset;
a calling component determining module 34, configured to determine, for each subset of state data to be modified, one or more calling components of the subset of state data;
a component update module 35, configured to update at least a part of the determined state data of each calling component.
For the principle, specific implementation and beneficial effects of the device for updating components, please refer to the related description about the method for updating components shown in fig. 1 to 2, and will not be described herein again.
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of the component updating method shown in fig. 1 and fig. 2. The computer-readable storage medium may include non-volatile (non-volatile) or non-transitory (non-transitory) memory, and may also include optical disks, mechanical hard disks, solid state disks, and the like.
Specifically, in the embodiment of the present invention, the processor may be a Central Processing Unit (CPU), and the processor may also be another general-purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or another programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
It will also be appreciated that the memory in the embodiments of the subject application may be either volatile memory or nonvolatile memory, or may include both volatile and nonvolatile memory. The nonvolatile memory may be a read-only memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable PROM (EEPROM), or a flash memory. Volatile memory can be Random Access Memory (RAM), which acts as external cache memory. By way of example and not limitation, many forms of Random Access Memory (RAM) are available, such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (enhanced SDRAM), synchronous DRAM (SLDRAM), synchronous Link DRAM (SLDRAM), and direct bus RAM (DR RAM).
An embodiment of the present invention further provides a terminal, which includes a memory and a processor, where the memory stores a computer program capable of running on the processor, and the processor executes the steps of the component updating method shown in fig. 1 and fig. 2 when running the computer program. The terminal can include but is not limited to a mobile phone, a computer, a tablet computer and other terminal devices, and can also be a server, a cloud platform and the like.
It should be understood that the term "and/or" herein is merely one type of association relationship that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein indicates that the former and latter associated objects are in an "or" relationship.
The "plurality" appearing in the embodiments of the present application means two or more.
The descriptions of the first, second, etc. appearing in the embodiments of the present application are only for illustrating and differentiating the objects, and do not represent the order or the particular limitation of the number of the devices in the embodiments of the present application, and do not constitute any limitation to the embodiments of the present application.
It should be noted that the sequence numbers of the steps in this embodiment do not represent a limitation on the execution sequence of the steps.
Although the present invention is disclosed above, the present invention is not limited thereto. Various changes and modifications may be effected therein by one skilled in the art without departing from the spirit and scope of the invention as defined in the appended claims.
Claims (16)
1. A component upgrade method, comprising:
determining a state data set of an application program, wherein the state data set is used for storing state data called by each component of the application program;
splitting the state data set to obtain state data subsets with preset splitting quantity;
determining a subset of state data to be modified;
for each subset of state data to be modified, determining one or more calling components of the subset of state data;
at least a portion of the determined state data for each calling component is updated.
2. The method of claim 1, wherein each state data in the state data set has a preset mapping relationship with one or more calling components.
3. The method of claim 1, wherein determining the subset of state data to be modified comprises:
receiving a state data subset modification instruction, wherein the state data subset modification instruction comprises indication information indicating the state data subset to be modified;
and determining the state data subset to be modified according to the received state data subset modification instruction.
4. The component update method of claim 2, wherein the updating at least a portion of the determined state data for each calling component comprises:
for each calling component, determining a state updating instruction of the calling component;
updating at least a portion of the state data of the calling component according to the determined state update instruction;
wherein the state update instruction of each calling component is used for indicating that at least one part of the state data of the calling component is updated.
5. The method of claim 4, wherein the state update instruction of each calling component is further configured to instruct that at least a portion of the state data of the calling component and the same state data in the subset of state data called by the calling component as at least a portion of the state data of the calling component are updated synchronously.
6. The method of claim 4, wherein each calling component consumes at least a portion of the state data in the called state data subset based on a state data subset calling instruction;
for each calling component, determining the state update instruction of the calling component comprises:
a state update instruction for the calling component is determined each time the state data subset consuming instruction for the calling component is executed.
7. The method of claim 6, wherein determining the state update instruction for the calling component each time the state data subset consuming instruction for the calling component is executed comprises:
each time a state data subset consuming instruction in the calling component is executed, a state data calling instruction is created and executed, and then a state updating instruction returned by the state data calling instruction is determined.
8. The method of any of claims 4 to 7, wherein after determining, for each calling component, the state update instruction for that calling component, the method further comprises:
adding the determined state update instruction to the state update instruction array.
9. The method of claim 7, wherein the state data call instruction is a UseState () function provided by constructing a user interface programming language library fact, and the state update instruction returned by the state data call instruction is a SetState () function provided by the fact.
10. The method of claim 1, wherein the individual components of the application form a component tree having a plurality of component levels, each component level having one or more components, each sub-component having one or more call state data called from a subordinate parent component;
the method further comprises the following steps:
determining a call state data set for each sub-component;
caching the current state data of each sub-component;
for each sub-component, judging whether the updated state data of the parent component has the state data of the calling state data set of the sub-component or not every time the state data of the parent component to which the sub-component belongs is updated;
if the judgment result is yes, updating the calling state data of the sub-component, which is the same as the updated state data, by adopting the updated state data for the updated state data of the calling state data set of the sub-component, and updating other state data of the sub-component by adopting the cache state data of the sub-component.
11. The method of claim 10, further comprising:
and if the judgment result is negative, updating all the state data of the sub-component by using the cached state data.
12. The method of claim 10, further comprising:
for each sub-component, caching the current state data of the component after updating the state data of the sub-component each time.
13. The method of claim 10, further comprising:
the current state data for each sub-component is periodically cached.
14. A component upgrade apparatus, comprising:
the system comprises a state data set determining module, a state data set determining module and a state data set judging module, wherein the state data set determining module is used for determining a state data set of an application program, and the state data set is used for storing state data called by each component of the application program;
the state data set splitting module is used for splitting the state data set to obtain state data subsets with preset splitting quantity;
the to-be-modified state data subset determining module is used for determining the to-be-modified state data subset;
the calling component determining module is used for determining one or more calling components of each state data subset to be modified;
and the component updating module is used for updating at least one part of the determined state data of each calling component.
15. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the component update method of any one of claims 1 to 13.
16. A terminal comprising a memory and a processor, the memory having stored thereon a computer program operable on the processor, wherein the processor, when executing the computer program, performs the steps of the component updating method of any of claims 1 to 13.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211058512.4A CN115576578A (en) | 2022-08-31 | 2022-08-31 | Component updating method and device, computer readable storage medium and terminal |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211058512.4A CN115576578A (en) | 2022-08-31 | 2022-08-31 | Component updating method and device, computer readable storage medium and terminal |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115576578A true CN115576578A (en) | 2023-01-06 |
Family
ID=84580158
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211058512.4A Pending CN115576578A (en) | 2022-08-31 | 2022-08-31 | Component updating method and device, computer readable storage medium and terminal |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115576578A (en) |
-
2022
- 2022-08-31 CN CN202211058512.4A patent/CN115576578A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9038022B2 (en) | Universal and adaptive software development platform for data-driven applications | |
US11853820B2 (en) | Cross-process communication method, apparatus, and device | |
CN109634490B (en) | List display method, device, equipment and storage medium | |
EP2727014B1 (en) | Automatic synchronization of most recently used document lists | |
US9069829B2 (en) | Data items manager | |
WO2021037050A1 (en) | Code change method and device | |
CN113641701B (en) | Data query method, system, heterogeneous acceleration platform and storage medium | |
CN110347399B (en) | Data processing method, real-time computing system and information system | |
CN106951231B (en) | Computer software development method and device | |
US11474796B1 (en) | Build system for distributed applications | |
CN113641338B (en) | Method and device for dynamically generating view component | |
EP3126968A1 (en) | Data view exposure mechanisms | |
CN112235132B (en) | Method, device, medium and server for dynamically configuring service | |
CN110599112B (en) | Network page development and maintenance method and device | |
CN115576578A (en) | Component updating method and device, computer readable storage medium and terminal | |
CN116048609A (en) | Configuration file updating method, device, computer equipment and storage medium | |
CN115809056A (en) | Component multiplexing implementation method and device, terminal equipment and readable storage medium | |
CN115167822A (en) | Branch code merging method, device, equipment and storage medium | |
US11372832B1 (en) | Efficient hashing of data objects | |
CN113961298A (en) | Page switching method, device, equipment and medium | |
CN113762702A (en) | Workflow deployment method, device, computer system and readable storage medium | |
JP2013105349A (en) | Updating and executing method of dynamic link library | |
US11907194B2 (en) | Systems and methods for executing and hashing modeling flows | |
CN111638903B (en) | Method and device for generating difference information of different software versions | |
CN110209746B (en) | Data processing method and device for data warehouse |
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 |