Data updating method and device, equipment and storage medium

CN117768323BActive Publication Date: 2026-08-21TENCENT TECH (BEIJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211163391.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-23
Publication Date
2026-08-21
Estimated Expiration
2042-09-23

AI Technical Summary

Technical Problem

但现有的数据观察方法要求开发者进行被观察者的硬编码,逐一添加被观察者的属性字段,稳定性和可维护性差;并且,现有的数据观察无法在程序运行时实现空数据的观察,可用性低,如在插件数据更新场景下,不能进行业务插件的空数据观察,进而无法实现业务插件的热插拔,降低应用运行性能

Benefits of technology

[0022]本申请的技术方案基于预设封装方法对目标应用程序的目标业务模型数据进行数据封装,得到目标业务模型数据对应的可观察对象;并确定可观察对象对应的目标更新对象,创建与目标更新对象和可观察对象关联的上下文对象;基于上下文对象对可观察对象进行数据采集,得到可观察对象的目标观察数据;进而响应于可观察对象的更新触发事件,基于上下文对象进行目标更新对象的数据更新;通过对应用程序中的目标业务模型数据进行封装,能够在目标业务模型数据为空的状态下,实现依赖收集,以得到和存储属性为空的观察数据,进而响应于更新事件,实现数据从空到非空状态的数据观察和数据更新;并且,通过目标业务模型数据封装、上下文对象创建、以及基于上下文对象进行数据采集和派发更新,降低代码开发和维护难度,实现目标业务模型数据的自动观察和更新,降低应用程序的广播事件量。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117768323B_ABST
    Figure CN117768323B_ABST
Patent Text Reader

Abstract

The application provides a data updating method and device, equipment and a storage medium, relates to the technical field of computers, can be applied to various scenes such as cloud technology, artificial intelligence, intelligent transportation and auxiliary driving, and the method comprises the following steps: performing data packaging on target business model data of a target application program based on a preset packaging method, to obtain an observable object corresponding to the target business model data; determining a target update object corresponding to the observable object, and the data update of the target update object depends on the state change of the target business model data; creating a context object associated with the target update object and the observable object; collecting data of the observable object based on the context object, to obtain target observation data of the observable object; and in response to an update trigger event of the observable object, performing data update on the target update object based on the context object. The application can realize empty data observation of a business model and intelligent data observation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a data updating method, apparatus, device, and storage medium. Background Technology

[0002] Data observation capabilities are a common feature in software development. In MVC (Model-View-Controller) or similar patterns, data observation is essential for view data updates. However, existing data observation methods require developers to hard-code the observed objects and add their attribute fields one by one, resulting in poor stability and maintainability. Furthermore, existing data observation methods cannot observe empty data at runtime, leading to low usability. For example, in plugin data update scenarios, it is impossible to observe empty data of business plugins, thus hindering hot-swapping of business plugins and reducing application performance. Summary of the Invention

[0003] This application provides a data update method, apparatus, device, and storage medium that can enable automatic observation and updating of target business model data, reducing the amount of broadcast events in the application.

[0004] On the one hand, this application provides a data update method, the method comprising:

[0005] Based on a preset encapsulation method, the target business model data of the target application is encapsulated to obtain the observable object corresponding to the target business model data.

[0006] Determine the target update object corresponding to the observable object, wherein the data update of the target update object depends on the state change of the target business model data;

[0007] Create a context object associated with the target update object and the observable object;

[0008] Data is collected from the observable object based on the context object to obtain the target observation data of the observable object;

[0009] In response to the update trigger event of the observable object, the data of the target update object is updated based on the context object.

[0010] On the other hand, a data updating device is provided, the device comprising:

[0011] Data encapsulation module: used to encapsulate the target business model data of the target application based on a preset encapsulation method, so as to obtain the observable object corresponding to the target business model data;

[0012] Object determination module: used to determine the target update object corresponding to the observable object, wherein the data update of the target update object depends on the state change of the target business model data;

[0013] Object creation module: Used to create a context object associated with the target update object and the observable object;

[0014] Data acquisition module: used to acquire data from the observable object based on the context object, and obtain the target observation data of the observable object;

[0015] Data update module: In response to the update trigger event of the observable object, update the data of the target update object based on the context object.

[0016] On the other hand, a computer device is provided, the device including a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the data update method as described above.

[0017] On the other hand, a computer-readable storage medium is provided, wherein at least one instruction or at least one program is stored therein, the at least one instruction or the at least one program being loaded and executed by a processor to implement the data update method as described above.

[0018] On the other hand, a server is provided, the server including a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the data update method as described above.

[0019] On the other hand, a terminal is provided, the terminal including a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the data update method as described above.

[0020] On the other hand, a computer program product or computer program is provided, which includes computer instructions that, when executed by a processor, implement the data update method as described above.

[0021] The data updating method, apparatus, device, storage medium, server, terminal, computer program, and computer program product provided in this application have the following technical effects:

[0022] The technical solution of this application encapsulates the target business model data of the target application using a preset encapsulation method to obtain observable objects corresponding to the target business model data; it then determines the target update object corresponding to the observable object and creates a context object associated with the target update object and the observable object; it collects data from the observable object based on the context object to obtain the target observation data of the observable object; and then, in response to the update trigger event of the observable object, it updates the data of the target update object based on the context object. By encapsulating the target business model data in the application, it is possible to achieve dependency collection even when the target business model data is empty, so as to obtain and store observation data with empty attributes, and then, in response to the update event, realize data observation and data update from empty to non-empty state. Furthermore, by encapsulating the target business model data, creating the context object, and collecting and distributing updates based on the context object, the difficulty of code development and maintenance is reduced, automatic observation and updating of the target business model data is achieved, and the amount of broadcast events in the application is reduced. Attached Figure Description

[0023] To more clearly illustrate the technical solutions and advantages in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1 This is a schematic diagram of an application environment provided in an embodiment of this application;

[0025] Figure 2 This is a flowchart illustrating a data update method provided in an embodiment of this application;

[0026] Figure 3 This is a schematic diagram of the playback interface of a video player provided in an embodiment of this application;

[0027] Figure 4 This is a schematic diagram of the playback interface of another video player provided in an embodiment of this application;

[0028] Figure 5 This is a schematic diagram of the process of creating an observable object provided in an embodiment of this application;

[0029] Figure 6 This is a schematic diagram illustrating the process of creating a context object and collecting dependencies provided in an embodiment of this application;

[0030] Figure 7 The diagram below illustrates the principle framework of a data update method according to this application.

[0031] Figure 8 This is a schematic diagram of an update distribution process provided in an embodiment of this application;

[0032] Figure 9 This is a schematic diagram of a data update system framework provided in an embodiment of this application;

[0033] Figure 10 This is a schematic diagram of the playback interface of another video player provided in an embodiment of this application;

[0034] Figure 11 This is a schematic diagram of the framework of a data update device provided in an embodiment of this application;

[0035] Figure 12 This is a hardware structure block diagram of an electronic device for a data update method provided in an embodiment of this application. Detailed Implementation

[0036] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0037] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that comprises a series of steps or sub-modules is not necessarily limited to those steps or sub-modules explicitly listed, but may include other steps or sub-modules not explicitly listed or inherent to such processes, methods, products, or devices.

[0038] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.

[0039] NSProxy: A utility class in the iOS programming language that can hook the getter or setter methods of an instance object.

[0040] MVC (Model-View-Controller): A software architecture pattern in software engineering that divides a software system into three basic parts: Model, View, and Controller.

[0041] Observer pattern: A software design pattern in which a target object manages all the observer objects that depend on it and actively sends out notifications when its own state changes. It is often used in real-time event processing systems.

[0042] Please see Figure 1 , Figure 1 This is a schematic diagram of an application environment provided in an embodiment of this application, such as... Figure 1 As shown, the application environment may include at least terminal 01 and server 02. In practical applications, terminal 01 and server 02 can be directly or indirectly connected via wired or wireless communication, and this application does not impose any restrictions on this.

[0043] In this application embodiment, server 02 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.

[0044] Specifically, cloud technology refers to a hosting technology that unifies hardware, software, and network resources within a wide area network (WAN) or local area network (LAN) to achieve data computation, storage, processing, and sharing. Cloud technology can be applied to various fields, such as medical cloud, cloud IoT, cloud security, cloud education, cloud conferencing, AI cloud services, cloud applications, cloud calling, and cloud social networking. Based on the cloud computing business model, cloud technology distributes computing tasks across a resource pool composed of numerous computers, enabling various application systems to obtain computing power, storage space, and information services as needed. The network providing these resources is called the "cloud." From the user's perspective, the resources in the "cloud" are infinitely scalable, readily available, on-demand, expandable, and pay-as-you-go. As a provider of basic cloud computing capabilities, a cloud resource pool (referred to as a cloud platform, generally called IaaS (Infrastructure as a Service)) platform is established, deploying various types of virtual resources within the pool for external customers to choose from. The cloud resource pool mainly includes: computing devices (virtualized machines containing operating systems), storage devices, and network devices.

[0045] Based on logical function, a PaaS (Platform as a Service) layer can be deployed on top of the IaaS layer, and a SaaS (Software as a Service) layer can be deployed on top of the PaaS layer. Alternatively, SaaS can be deployed directly on top of IaaS. PaaS is a platform for running software, such as databases and web containers. SaaS refers to various types of business software, such as web portals and bulk SMS senders. Generally speaking, SaaS and PaaS are upper layers compared to IaaS.

[0046] Specifically, the server 02 mentioned above may include physical devices, such as network communication submodules, processors, and memory, and may also include software running on the physical devices, such as applications.

[0047] Specifically, terminal 01 may include physical devices such as smartphones, desktop computers, tablets, laptops, digital assistants, augmented reality (AR) / virtual reality (VR) devices, smart voice interaction devices, smart home appliances, smart wearable devices, and in-vehicle terminal devices, and may also include software running on the physical devices, such as applications.

[0048] In this embodiment, terminal 01 can run a target application to provide data observation and data update services. Specifically, during the startup or operation of the target application, the target business model data of the target application is encapsulated to obtain observable objects, and the target update object corresponding to the target business model data is determined. A context object associated with both is created, and then the dependency collection of observable objects and the dispatch and update of target update objects are performed based on the context object. Server 02 can respond to the data acquisition request of the target application of terminal 01, provide data support services, and can also receive and store the running data sent by the target application of terminal 01.

[0049] Furthermore, it is understandable that Figure 1 The example shown is merely an application environment for one data update method. This application environment may include more or fewer nodes, and this application does not impose any restrictions here.

[0050] The following describes a data update method based on the aforementioned application environment. This application's embodiments can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, and assisted driving. Please refer to... Figure 2 , Figure 2 This is a flowchart illustrating a data update method provided in an embodiment of this application. This specification provides method operation steps as shown in the embodiments or flowcharts, but based on conventional or non-inventive labor, more or fewer operation steps may be included. The order of steps listed in the embodiments is merely one possible execution order among many and does not represent the only execution order. In actual system or server product execution, the method can be executed sequentially according to the embodiments or drawings, or in parallel (e.g., in a parallel processor or multi-threaded processing environment). Specifically, as... Figure 2 As shown, the method may include the following steps S201-S209.

[0051] S201: Based on a preset encapsulation method, encapsulate the target business model data of the target application to obtain the observable object corresponding to the target business model data.

[0052] In this embodiment, the target application can be a program based on the MVC or MVC-like software architecture pattern, and may include, but is not limited to, video players, browser programs, and social applications. The target application has at least one business model, and the target business model data may include attribute configuration data of the business model, etc. The business model may include, but is not limited to, program components or plugins. Taking a video player as an example, the business model can be a business plugin used by the video player; correspondingly, the target business model data is the business plugin data. Please refer to... Figure 3 and Figure 4The figure shows the playback interface 100 of the video player. The part enclosed by the dashed box is the trigger control 101 of the business plugin in the player.

[0053] In practical applications, a wrapper instance corresponding to the target business model data is created based on a preset wrapper method. The attribute acquisition and modification methods for the target business model data are then configured based on the wrapper instance to obtain an observable object. Specifically, the preset wrapper method can be implemented based on a predefined interface (such as the `reactive()` interface). This preset wrapper method defines the usage logic for the target business model data, used to implement data interception configuration for the target business model data, thereby generating an observable object. This observable object is a reactive object, capable of participating in the dependency collection process. In this way, the target business model data is wrapped from a regular object into an observable object, facilitating subsequent references and callbacks to the context object. This enables the rapid creation of a one-to-many observation pattern, reducing code writing requirements. Simultaneously, wrapping the model's original data allows dependency collection to be performed even when the data is empty, thus enabling the observation of an empty data model.

[0054] Specifically, the target business model data is the original data (originData) of the business model, which is a regular object relative to the observable object. The target business model data is input into a predefined interface, and a wrapper instance is created based on a predefined utility class corresponding to a predefined wrapper method. This utility class can be configured based on the operating system type or the system programming language requirements, such as using NSPorxy provided by Objective-C. Further, based on hook functions, the property acquisition methods (generalized getter methods) and property modification methods (generalized setter methods) of the target business model data are configured within the wrapper instance to intercept and configure the target business model data, resulting in an observable object with the hooked generalized getter methods and / or generalized setter methods, which serves as the basis for subsequent dependency collection and other data processing operations.

[0055] In one embodiment, the data encapsulation of the target business model data is implemented based on the NSPorxy utility class. Please refer to [link / reference]. Figure 5 The process includes the following steps: S11. Obtain the target business model data (originData); S12. Input the target business model data into the predefined interface (reactive(originData)); S13. Create a wrapper instance (NSPorxy instance); S14. Hook the generalized getter method within the NSPorxy instance; S15. Hook the generalized setter method within the NSPorxy instance; S16. Generate an observable object (NSPorxy instance object).

[0056] In some embodiments, data encapsulation of the target business model data can be triggered based on the startup of the target application or during the operation of the target application. Specifically, data encapsulation is performed before the business model (such as a business plugin) to which the target business model data belongs is loaded to generate observable objects. Thus, data encapsulation is performed when the target attribute value in the target business model data is empty, and then subsequent dependency collection is performed to obtain target observation data with an empty target attribute value, so as to realize data observation from empty to non-empty data.

[0057] S203: Determine the target update object corresponding to the observable object.

[0058] In this embodiment, the data update of the target update object depends on the state change of the target business model data, which is equivalent to the observer object corresponding to the observable object. For example, in the MVC pattern, the target business model data of Model A is encapsulated to generate an observable object A, which depends on View A of Model A. View B and View C are the target update objects corresponding to Model A.

[0059] In practical applications, the dependencies between business model data and multiple update objects in the target application are obtained. Based on these dependencies, update objects that depend on the target business model data are identified as target update objects. Specifically, if the target application contains multiple update objects, such as multiple Views, the update objects that dynamically update depending on updates to the target business model data are selected to determine the target update objects. These dependencies can be obtained from a pre-stored dependency table, which stores one or more update objects corresponding to each piece of business model data. In this way, by identifying the target update objects in the application that depend on the target business model data through dependencies, the necessary relationships for dependency collection are established, facilitating the concurrent creation and dependency collection of context objects corresponding to different update objects.

[0060] S205: Create a context object associated with the target update object and the observable.

[0061] In this embodiment, the context object includes environmental information required for dependency collection and data updates of the target update object. Specifically, a preset closure corresponding to the target update object is obtained. The preset closure includes business logic code segments for executing data updates of the target update object. Through the preset closure, various required data of the observable object can be accessed directly or indirectly. The preset closure is passed to a preset internal function to create a context object, which holds the preset closure. The internal function can be a preset dependency collection function used to define the execution method of dependency collection. The context object is associated with the observable object; specifically, the pointer of the context object references the observable object. Specifically, by executing the preset closure of the context object, the invocation of the attribute acquisition method of the observable object can be triggered.

[0062] S207: Collect data from observable objects based on context objects to obtain target observation data of observable objects.

[0063] In this embodiment, the data acquisition is based on dependency collection. Dependency collection is a technique that allows a program to determine whether data is used and by whom during runtime. The aforementioned internal function defines the implementation method of the data acquisition, i.e., dependency collection. As mentioned above, the context object includes the preset closure corresponding to the target update object. Accordingly, S207 may include the following steps S2071-S2073:

[0064] S2071: Add the context object to the sequence of execution elements;

[0065] S2072: Read the attribute data of the observable object based on the preset closure of the context object to obtain the target observation data;

[0066] S2073: Store the target observation data in association with the context object and the observable object.

[0067] In practical applications, the execution element sequence can be a predefined global element sequence. After creating the context object, it is added to the beginning of the execution order of the execution element sequence. The predefined closure within the context object is then executed to trigger the property getter method call of the observable object, i.e., to trigger the call of the observable object's generalized getter method. This allows access to the target attribute field in the observable object, obtaining the target observation data. Then, within the attribute getter method, the target observation data, the context object, and the observable object are associated and stored based on a predefined data structure. Specifically, the target observation data can include the target attribute field and its current value. It can be stored using the observable object's identifier or the target attribute field as the key, and the context object and the current attribute value as the value. In this way, the attribute data of the observable object is accessed and read through the attribute getter method call, enabling the collection and associated storage of empty data dependencies in the business model. This provides the context information required for subsequent data updates, ensuring that the business update logic is informed when data updates are triggered.

[0068] Understandably, after the target application starts, if the target business model is not loaded or triggered, the current attribute value of the target attribute field in the observable object is empty (nil). By calling the getter method to obtain the target attribute field required by the target update object to perform the update business, and recording its empty state, it is possible to collect empty data dependencies of the business model, thereby providing context information for subsequent attribute modification method triggering.

[0069] Specifically, the execution element sequence can be implemented using a stack. A global stack is defined, and the aforementioned context object is pushed onto the top of the stack. The current context object at the top of the stack records the current preset closure. Running this preset closure triggers the aforementioned getter method, retrieving the target attribute field and its corresponding value. Using the accessed target attribute field as the key, the effect object at the top of the stack and the target attribute field as the value are stored in a data table. This allows, when a subsequent attribute modification method (generalized setter method) is triggered, the effect object and the key of the target attribute field can be determined based on the attribute modification method's function, allowing the context object to be retrieved from the data table and the preset closure to be re-executed.

[0070] Furthermore, after obtaining the target observation data, that is, after the preset closure is executed, the context object is removed from the sequence of execution elements. In the case of a stack, this operation is called popping the context object from the stack.

[0071] In some cases, the preset closure contains nested inner functions. When the preset closure includes nested inner functions, a context object corresponding to each inner function is added to the execution element sequence. Correspondingly, based on the element order of the execution element sequence, each inner function is called sequentially to read the attribute data of the observable object, obtaining the target observable data. This ensures a one-to-one correspondence between the currently executing preset closure and the context object at the first position in the execution element sequence. For example, using an execution stack, the context object recorded at the top of the stack corresponds one-to-one with the currently running preset closure, avoiding dependency collection failures caused by nested function calls.

[0072] In one embodiment, please refer to Figure 6 , Figure 6 The following describes the context object creation and dependency collection process in an example: S21. Passing a predefined closure (Closure) into the inner function (Effect()), where Effect(() => {info = reactiveData["extro"];}), reactiveData is the observable object, and extro is the attribute field or identifier field of the observable object; S22. Creating a context object (effectObject1 = new Effect()), which holds the Closure; S23. Pushing effectObject1 onto the stack; S24. Executing the Closure to obtain the target observable data, and within the getter method of reactiveData, storing effectObject1 from the stack into the effectObject array corresponding to extro, establishing a data structure that describes the relationship between effectObject1, reactiveData, observable Data, and the extro field; S25. After the closure execution is complete, popping effectObject1 from the stack. With extro as the key, it's understandable that the data table also includes effectObjec arrays corresponding to other keys, used to store the context objects corresponding to those other keys.

[0073] S209: In response to an update trigger event of an observable object, update the data of the target update object based on the context object.

[0074] In this embodiment, when the data of an observable object is updated, such as when a business model is enabled (e.g., when a business plugin is loaded), the target attribute value in the target business model data changes from empty to non-empty, indicating a data update. This triggers the invocation of the observable object's attribute modification method (generalized setter method), thus generating an update trigger event. In other words, the trigger condition for the data update of the target object is a change in the data state of the observable object.

[0075] In one embodiment, please refer to Figure 7 , Figure 7 The diagram illustrates the principle framework of the data update method of this application. The target business model data has multiple dependent target update objects, which are encapsulated to obtain observable objects. Context object 1 is associated with the observable objects, target update object 1, and target update object 2 of the target business model data. Context object 2 is associated with the observable objects and target update object n of the target business model data. Data collection is performed on the observable objects based on context object 1 to obtain the target observation data required by target update object 1 and target update object 2. Data collection is performed on the observable objects based on context object 2 to obtain the target observation data required by target update object n.

[0076] Taking a video playback application as an example, please refer to... Figure 10The target business model data is the business model data of the video player's error plugin. Multiple target update objects dependent on the error plugin include an error panel and a retry control. The diagram shows the first display interface 1 and the second display interface 2 corresponding to the error panel, and the third display interface 3 corresponding to the retry control. This error plugin is not triggered when the video player starts; it is only triggered when there are playback errors such as network errors. Understandably, before the error plugin loads and before playback errors occur, the first display interface, second display interface 2, and third display interface 3 are not displayed on the video player's playback interface. Before the error plugin loads, its business model data is encapsulated to obtain an observable object, and a context object 'a' is created associated with the observable object and the error panel, as well as a context object 'b' associated with the observable object and the retry control. Data is then collected from the observable object based on context object 'a'. The corresponding target observation data is obtained. Based on context object b, data is collected from the observable object to obtain the corresponding target observation data. It is understandable that when the error plugin is not loaded, the attribute values ​​of the target attribute fields contained in the obtained target observation data are all empty. After a network error or other event occurs, the loading of the error plugin is triggered, that is, an update trigger event for the observable object is generated. Then, based on context object a, the target observation data updated by the error plugin loading is collected, and the error panel is updated. Based on context object b, the target observation data updated by the error plugin loading is collected, and the retry control is updated. Error information such as "Video loading failed, please try again later" is displayed in the first display interface 1, error code such as "20300.10103" is displayed in the second display interface 2, and retry prompt information such as "Click to retry" is displayed in the third display interface 3.

[0077] Accordingly, S209 may include the following S2091-S2092.

[0078] S2091: In response to the update trigger event of the observable, update data is collected on the observable based on the context object to obtain the updated target observation data;

[0079] S2092: Based on the context object, call the preset execution method of the target update object to update the target observation data.

[0080] In practical applications, the above data update process is re-executed based on the context object to collect updated data. Specifically, in response to the update trigger event of the observable object, the context object created and stored in the previous dependency collection is obtained according to the property modification method (setter method) of the observable object. Specifically, the key of the context object in the previous dependency collection (such as the aforementioned extro) can be concatenated through the setter method, and then the corresponding context object is retrieved from storage. The context object is added to the execution element sequence again, and the property data of the observable object is read based on the preset closure of the context object to obtain the updated target observation data. This data collection process is similar to that described above and will not be repeated here.

[0081] As mentioned earlier, the predefined closure includes the business logic code segment that executes the data update of the target update object. Through the predefined closure, various data of the observable object can be accessed directly or indirectly. Correspondingly, based on the predefined closure, the predefined execution method of the target update object can be called, that is, the predefined execution method is called based on the business logic code segment to realize the update processing of the target observed data, i.e., to realize the dispatch update of the target update object. Thus, in response to data update events, update dependency collection and update business logic execution of the update object are achieved collaboratively based on the context object. This enables the observation of non-empty data in the business model from empty data to non-empty data while simultaneously updating the data of the update object, improving data update efficiency and enabling hot-swapping of the business model.

[0082] In some embodiments, in response to an update trigger event of an observable object, the target observation data is deleted. Accordingly, after S2091, the method further includes storing the updated target observation data in association with the context object and the observable object. Thus, during the process of monitoring the change of the attribute value of a target attribute field from empty to non-empty, and clearing the data structure established in the previous dependency collection, the method responds to changes in the target attribute field in the observer object, such as removing target attribute fields that are no longer needed for observation, or adding new target attribute fields that need to be observed, to establish a new data structure and update the dependencies in the dependency collection, responding to real-time state changes.

[0083] In one embodiment, please refer to Figure 8The document illustrates a dispatch update process for a target update object, including: S31. Updating the target attribute value of the observable object; S32. Determining if the old and new values ​​of the target attribute of the observable object are the same. If they are the same, the operation ends; otherwise, proceed to S33; S33. Searching for the effectObject collected in the previous dependency collection process based on the setter method of the observable object; S34. Determining if the effectObject exists. If it exists, proceed to S35; otherwise, the operation ends; S35. Clearing the data structure established in the previous dependency collection process (including clearing the target observation data collected in the previous process); S36. Pushing the effectObject onto the stack again; S37. Executing the preset closure of the effectObject. During execution, dependency collection is retried to obtain the updated target observation data, and the update business logic of the corresponding target update object is executed; S38. Establishing a new data structure based on the updated target observation data.

[0084] In some embodiments, the data update method of this application can be based on Figure 9The system framework implementation consists of three parts. The first part is the input, which includes the target business model data (originData) and encapsulates it to generate an observable object, reactive(originData), which hooks the setter and getter methods. The second part is dependency collection. The initial dependency collection process executes the preset closure of the context object, then calls the getter method to obtain the target observation data, stores it in a data table, and establishes a data structure based on the target observation data and the current context object (effectObjec). The third part is update dispatch. In response to the data update event of reactive(originData), the setter method is called to find the multiple context objects (effectObjecs, including effectObjec1, effectObjec2, etc.) corresponding to reactive(originData), and then executes the closures corresponding to the multiple context objects (runeffectObjec1, effectObjec2, etc.). Through the collaboration between the input, dependency collection, and update dispatch parts of the system framework, the input part allows business logic to define access to empty data during the target application's runtime and execute key logic for data observation, access, and retrieval from empty to non-empty data. The dependency collection part establishes the key data structures for the entire system runtime. The update dispatch part then executes the key business logic predefined by the input part based on the key data structures established by dependency collection, enabling the entire system to observe empty data. Based on the above method, it is known whether a business model's data is used and by which update objects. Combined with the generalized hook in the first part, it is only necessary to find the corresponding context object within its generalized setter to execute the context object's closure again, thereby executing the update business logic required by the target update object. Simultaneously, during the closure execution, dependency collection can be re-triggered, thus establishing a data observation process from empty to non-empty, coordinating data observation, dependency relationship updates, and update object data updates.

[0085] The following example illustrates the data update method using a video player as the target application, an error message plugin for the video player as the business model, and the error panel of the error plugin as the target update object. Please refer to [link / reference]. Figure 10 , Figure 10The code displays a video playback page with an error panel from the error plugin. The panel shows the message "Video loading failed, please try again later," error code "20300.10103," and a retry control "Click to Retry." This error panel only pops up when video playback fails, providing partial error information. The error plugin's business model data corresponds to observable objects, while the retry control and error panel are the target update objects. In some cases, the video player plugin is further encapsulated, referencing the same business model to achieve unified observable calls, such as referencing `videoManager` as described below, which is then encapsulated as an observable object.

[0086] Understandably, based on the above data update method, hot-swapping of plugins can be achieved, eliminating the need to load all plugins at startup. On-demand loading is possible, prioritizing the player for video playback upon entering the player playback page, and loading necessary business plugins, such as VIP membership plugins and advertising plugins, in non-UI threads. Other business plugins, such as error plugins, are loaded on demand. These error plugins are triggered and created when a network error is thrown by the underlying network library, but are not loaded during normal playback, thus speeding up loading and reducing memory consumption.

[0087] For example, the code used in the video player is as follows: Since the error plugin is loaded on demand, that is, in the case of erroroccured, the error plugin is loaded. Before loading, its upper-level videoManager has been encapsulated to generate an observable object, and a context object associated with the error plugin and the error panel and retry control corresponding to the error plugin is created. This context object holds the VLEffect closure. Executing the VLEffect closure, the initial dependency collection is carried out based on the getter method of the observable object, the target observation data is obtained, and the data structure is established. At this time, the target attribute field videoManager is obtained by dependency collection. The `errorPlugin.title` property is initially empty (nil). When a network error or other event occurs, the error plugin is loaded, the `videoManager.errorPlugin.title` property changes and becomes non-empty, triggering the setter method of the error plugin's observable object to perform dependency collection again, obtain updated target observable data (including error content, error code, etc.), and trigger the preset execution methods of the error panel and retry control to update them. For example, the preset execution method of the error panel (`displayErrorTitle:`) is triggered to automatically display the error information such as the aforementioned error code.

[0088]

[0089] Specifically, based on the code snippet above, after the `displayErrorInfoIfNeed` call, the default closure (VLEffect) is executed immediately. During the execution of the VLEffect closure, the dependency collection part is entered, including: 1. The dependency collection system creates a context object `effectObjec1` at the top of the stack; 2. The getter method of `videoManager` (the observable object) accesses the `errorPlugin` field, which is currently empty, and records that `videoManager` needs to observe "errorPlugin", and its corresponding context is `effectObjec1`; 3. After dependency collection is complete, if the underlying network library throws an error, `errorOccured` is called; 4. `NetErrorPlugin` is created, and the `setter` method of `videoManager` is implicitly called, triggering update dispatch; 5. During update dispatch, the VLEffect closure is executed again based on the context `effectObjec1` corresponding to "errorPlugin", confirming that the condition `videoManager.errprPlugin.title.length > 0` is true; 6. Then, the default execution method of the error panel is executed to display error information on the player interface.

[0090] In summary, the data update method of this application can be widely applied to various applications based on MVC or MVC-like patterns. It enables observation of data models containing empty data during program runtime, as well as chained observation of data models to achieve multi-level attribute acquisition and modification. Even empty data at chained nodes can be observed, thus enabling hot-swapping of the program, such as hot-swapping of business plugins for media players. This hot-swapping allows for cross-scenario reuse of video players, improving playback performance. In video player scenarios, because plugins can be hot-swapped, player loading time is reduced by more than 51%. Furthermore, because it enables intelligent and dynamic observation of the observed object, it significantly reduces the code complexity and coupling of video player business plugins, thereby effectively reducing the manual cost of business development. In media player scenarios, broadcast events are reduced by more than 64.3%.

[0091] This application embodiment also provides a data update device 600, such as... Figure 11 As shown, Figure 11 The diagram shows a structural schematic of a data update device provided in an embodiment of this application. The device may include the following modules.

[0092] Data encapsulation module 10: used to encapsulate the target business model data of the target application based on a preset encapsulation method to obtain the observable object corresponding to the target business model data;

[0093] Object determination module 20: used to determine the target update object corresponding to the observable object, the data update of the target update object depends on the state change of the target business model data;

[0094] Object creation module 30: Used to create context objects associated with the target update object and observables;

[0095] Data acquisition module 40: used to acquire data from observable objects based on context objects, and obtain target observation data of observable objects;

[0096] Data update module 50: Used to update the data of the target update object based on the context object in response to the update trigger event of the observable object.

[0097] In some embodiments, the data encapsulation module 10 may include:

[0098] The instance creation submodule is used to create encapsulated instances corresponding to the target business model data based on preset encapsulation methods.

[0099] The attribute configuration submodule is used to configure the attribute acquisition and attribute modification methods of the target business model data based on the encapsulated instance, and obtain the observable object.

[0100] In some embodiments, the object determination module 20 may include:

[0101] Dependency Acquisition Submodule: Used to obtain the dependency relationships between business model data and multiple update objects in the target application;

[0102] Update Object Determination Submodule: Used to determine the update objects that depend on the target business model data as the target update objects based on dependency relationships.

[0103] In some embodiments, the context object includes a preset closure corresponding to the target update object, and the data acquisition module 40 may include:

[0104] Adding a submodule to an object: This is used to add the context object to the sequence of execution elements;

[0105] The attribute reading submodule is used to read attribute data from observable objects based on the preset closure of the context object, and obtain the target observation data.

[0106] Storage submodule: Used to store target observation data in association with context objects and observable objects.

[0107] In some embodiments, the object adding submodule can be specifically used to add a context object for each inner function in the sequence of execution elements, for each inner function in the nested inner functions, when the preset closure includes nested inner functions.

[0108] Correspondingly, the attribute reading submodule can be specifically used to sort elements based on the execution element sequence, sequentially calling each inner function in the nested inner functions to read attribute data of the observable object, and obtain the target observation data.

[0109] In some embodiments, the data update module 50 may include:

[0110] Update data acquisition submodule: In response to update trigger events of observable objects, update data acquisition of observable objects based on context objects to obtain updated target observation data;

[0111] Update processing submodule: Used to call the preset execution method of the target update object based on the context object to update the target observation data.

[0112] In some embodiments, the apparatus may further include:

[0113] Data deletion module: Used to delete target observation data in response to update trigger events of observable objects;

[0114] Update storage module: After collecting update data on observables based on context objects and obtaining updated target observation data, store the updated target observation data and associate it with the context objects and observables.

[0115] It should be noted that the above-described device embodiments and method embodiments are based on the same implementation methods.

[0116] This application provides a data update device. The scheduling device can be a terminal or a server, including a processor and a memory. The memory stores at least one instruction or at least one program. The at least one instruction or at least one program is loaded and executed by the processor to implement the data update method provided in the above method embodiments.

[0117] Memory can be used to store software programs and modules. The processor executes various functional applications and data updates by running the software programs and modules stored in memory. Memory can primarily include a program storage area and a data storage area. The program storage area can store the operating system, application programs required for functionality, etc.; the data storage area can store data created based on device usage, etc. Furthermore, memory can include high-speed random access memory, and can also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, memory can also include a memory controller to provide the processor with access to the memory.

[0118] The methods and embodiments provided in this application can be executed in electronic devices such as mobile terminals, computer terminals, servers, or similar computing devices. Figure 12 This is a hardware structure block diagram of an electronic device for a data update method provided in an embodiment of this application. For example... Figure 12 As shown, the electronic device 900 can vary significantly due to different configurations or performance. It may include one or more Central Processing Units (CPUs) 910 (CPUs 910 may include, but are not limited to, microprocessors such as MCUs or programmable logic devices such as FPGAs), a memory 930 for storing data, and one or more storage media 920 (e.g., one or more mass storage devices) for storing application programs 923 or data 922. The memory 930 and storage media 920 may be temporary or persistent storage. The program stored in the storage media 920 may include one or more modules, each module including a series of instruction operations on the electronic device. Furthermore, the CPU 910 may be configured to communicate with the storage media 920 and execute a series of instruction operations in the storage media 920 on the electronic device 900. The electronic device 900 may also include one or more power supplies 960, one or more wired or wireless network interfaces 950, one or more input / output interfaces 940, and / or one or more operating systems 921, such as Windows Server. TM Mac OS X TM Unix TM Linux™, FreeBSD™, etc.

[0119] The input / output interface 940 can be used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the electronic device 900. In one example, the input / output interface 940 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the input / output interface 940 may be a radio frequency (RF) module for wireless communication with the Internet.

[0120] Those skilled in the art will understand that Figure 12 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, the electronic device 900 may also include... Figure 12 The more or fewer components shown, or having the same Figure 12 The different configurations shown.

[0121] Embodiments of this application also provide a computer-readable storage medium, which can be disposed in an electronic device to store at least one instruction or at least one program related to implementing a data update method in the method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement the data update method provided in the above method embodiment.

[0122] Optionally, in this embodiment, the storage medium may be located at at least one of the multiple network servers in a computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0123] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various alternative implementations described above.

[0124] As can be seen from the embodiments of the data update method, apparatus, device, server, terminal, storage medium, and program product provided in this application, the technical solution of this application encapsulates the target business model data of the target application based on a preset encapsulation method to obtain the observable object corresponding to the target business model data; determines the target update object corresponding to the observable object, and creates a context object associated with the target update object and the observable object; collects data from the observable object based on the context object to obtain the target observation data of the observable object; and then, in response to the update trigger event of the observable object, updates the data of the target update object based on the context object. By encapsulating the target business model data in the application, dependency collection can be achieved even when the target business model data is empty, so as to obtain and store the observation data with empty attributes. In response to the update event, the data observation and data update from empty and non-empty states can be realized. Furthermore, by encapsulating the target business model data, creating the context object, and collecting and distributing updates based on the context object, the difficulty of code development and maintenance is reduced, automatic observation and updating of the target business model data is realized, and the amount of broadcast events in the application is reduced.

[0125] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, the above description focuses on specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired results. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired results. In some implementations, multitasking and parallel processing are also possible or may be advantageous.

[0126] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device, equipment, and storage medium embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0127] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware, or by a program instructing the relevant hardware to implement them. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0128] The above are merely preferred embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A data update method, characterized in that, The method includes: Based on the startup or running process of the target application, before the business model to which the target business model data belongs is loaded, and when the target attribute value in the target business model data is empty, the target business model data of the target application is encapsulated based on a preset encapsulation method to obtain the observable object corresponding to the target business model data; the observable object is an object that can participate in the dependency collection process, and is obtained by configuring the attribute acquisition method and attribute modification method of the target business model data based on the encapsulation instance. Determine the target update object corresponding to the observable object, wherein the data update of the target update object depends on the state change of the target business model data; Create a context object associated with the target update object and the observable object; the context object includes environmental information required for dependency collection and data updates of the target update object; the context object includes a preset closure corresponding to the target update object; Based on the execution of the preset closure of the context object, the attribute acquisition method of the observable object is called to collect data on the observable object based on dependency collection, and the target observation data of the observable object with the target attribute value being empty is obtained. In response to the update trigger event of the observable object, the data of the target update object is updated based on the context object according to the attribute modification method of the observable object.

2. The method according to claim 1, characterized in that, The process of encapsulating the target business model data of the target application based on a preset encapsulation method to obtain observable objects corresponding to the target business model data includes: Create an encapsulation instance corresponding to the target business model data based on the preset encapsulation method; Based on the encapsulated instance, configure the attribute acquisition method and attribute modification method of the target business model data to obtain the observable object.

3. The method according to claim 1, characterized in that, Determining the target update object corresponding to the observable object includes: Obtain the dependencies between the business model data and multiple update objects of the target application; Based on the aforementioned dependency relationship, the update object that depends on the target business model data is identified as the target update object.

4. The method according to any one of claims 1-3, characterized in that, The context object includes a preset closure corresponding to the target update object. The step of collecting data from the observable object based on the context object to obtain the target observation data of the observable object includes: Add the context object to the sequence of execution elements; The target observation data is obtained by reading the attribute data of the observable object based on the preset closure of the context object; The target observation data is associated and stored with the context object and the observable object.

5. The method according to claim 4, characterized in that, Adding the context object to the sequence of execution elements includes: When the preset closure includes nested inner functions, for each of the nested inner functions, a context object corresponding to each inner function is added to the sequence of execution elements.

6. The method according to claim 5, characterized in that, The step of reading attribute data from the observable object based on the preset closure of the context object to obtain the target observation data includes: Based on the element sorting of the execution element sequence, each inner function in the nested inner function is called sequentially to read the attribute data of the observable object, thereby obtaining the target observation data.

7. The method according to any one of claims 1-3, 5 and 6, characterized in that, The step of updating the data of the target update object based on the context object in response to the update trigger event of the observable object includes: In response to the update trigger event of the observable object, update data is collected on the observable object based on the context object to obtain updated target observation data; Based on the context object, the preset execution method of the target update object is invoked to update the target observation data.

8. The method according to claim 7, characterized in that, The method further includes: In response to an update trigger event of the observable object, delete the target observation data; After updating the target observation data by collecting data on the observable based on the context object, the method further includes: The updated target observation data is stored in association with the context object and the observable object.

9. A data update device, characterized in that, The device includes: Data encapsulation module: Based on the startup or running process of the target application, before the business model to which the target business model data belongs is loaded, and when the target attribute value in the target business model data is empty, the module encapsulates the target business model data of the target application using a preset encapsulation method to obtain the observable object corresponding to the target business model data; the observable object is an object that can participate in the dependency collection process, and is obtained by configuring the attribute acquisition method and attribute modification method of the target business model data based on the encapsulation instance; Object determination module: used to determine the target update object corresponding to the observable object, wherein the data update of the target update object depends on the state change of the target business model data; Object creation module: used to create a context object associated with the target update object and the observable object; the context object includes environmental information required for dependency collection and data update of the target update object; the context object includes a preset closure corresponding to the target update object; Data acquisition module: Based on the execution of the preset closure of the context object, it calls the attribute acquisition method of the observable object, performs dependency-based data collection on the observable object, and obtains the target observation data of the observable object with the target attribute value being empty; Data update module: In response to the update trigger event of the observable object, update the data of the target update object based on the context object according to the attribute modification method of the observable object.

10. The apparatus according to claim 9, characterized in that, The data encapsulation module includes: Instance creation submodule: used to create an encapsulated instance corresponding to the target business model data based on the preset encapsulation method; The attribute configuration submodule is used to configure the attribute acquisition method and attribute modification method of the target business model data based on the encapsulated instance, so as to obtain the observable object.

11. The apparatus according to claim 9, characterized in that, The object determination module includes: Dependency Acquisition Submodule: Used to acquire the dependency relationships between business model data and multiple update objects of the target application; Update Object Determination Submodule: Used to determine the update object that depends on the target business model data as the target update object based on the dependency relationship.

12. The apparatus according to any one of claims 9-11, characterized in that, The data acquisition module includes: Object Addition Submodule: Used to add the context object to the sequence of execution elements; Attribute reading submodule: used to read attribute data of the observable object based on the preset closure of the context object, and obtain the target observation data; Storage submodule: Used to associate and store the target observation data with the context object and the observable object.

13. The apparatus according to claim 12, characterized in that, The purpose of adding a submodule to the object is specifically to: When the preset closure includes nested inner functions, for each of the nested inner functions, a context object corresponding to each inner function is added to the sequence of execution elements.

14. The apparatus according to claim 13, characterized in that, The attribute reading submodule is specifically used for: Based on the element sorting of the execution element sequence, each inner function in the nested inner function is called sequentially to read the attribute data of the observable object, thereby obtaining the target observation data.

15. The apparatus according to any one of claims 9-11, 13 and 14, characterized in that, The data update module includes: Update data acquisition submodule: In response to the update trigger event of the observable object, update data acquisition is performed on the observable object based on the context object to obtain updated target observation data; Update processing submodule: used to call the preset execution method of the target update object based on the context object to update the target observation data.

16. The apparatus according to claim 15, characterized in that, The device further includes: Data deletion module: used to delete the target observation data in response to an update trigger event of the observable object; Update storage module: After the update data acquisition of the observable object based on the context object is performed to obtain the updated target observation data, the updated target observation data is stored in association with the context object and the observable object.

17. A computer-readable storage medium, characterized in that, The storage medium stores at least one instruction or at least one program segment, which is loaded and executed by a processor to implement the data update method as described in any one of claims 1-8.

18. A computer device, characterized in that, The device includes a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the data update method as described in any one of claims 1-8.

19. A computer program product, characterized in that, The computer program product includes computer instructions that, when executed by a processor, implement the data update method as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Installation-free program conversion processing method and device, electronic equipment and storage medium

    CN111176648A

  • Business processing system and method

    CN112860454A