CN110659299B - Data update method and device, front-end development client - Google Patents
Data update method and device, front-end development client Download PDFInfo
- Publication number
- CN110659299B CN110659299B CN201910818052.2A CN201910818052A CN110659299B CN 110659299 B CN110659299 B CN 110659299B CN 201910818052 A CN201910818052 A CN 201910818052A CN 110659299 B CN110659299 B CN 110659299B
- Authority
- CN
- China
- Prior art keywords
- update
- source data
- data
- request
- middleware
- 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.)
- Withdrawn - After Issue
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
技术领域technical field
本发明涉及计算机领域,具体而言,涉及一种数据更新的方法及装置、前端开发客户端。The present invention relates to the field of computers, and in particular, to a method and device for updating data, and a front-end development client.
背景技术Background technique
相关技术中,软件包括前端和后端,分别需要对应的工具进行开发。In the related art, the software includes a front-end and a back-end, which respectively require corresponding tools for development.
相关技术中,Angular作为前端开发的主流框架之一,通常使用服务对中间数据状态进行缓存,再通过依赖注入的方式,引入该服务的组件能够共享缓存数据,并且都有权限去修改,因此容易造成组件篡改缓存数据而导致错误,并且无法跟踪。另外一个组件更改缓存数据后,需要将数据同步至其他引用了相同服务的组件当中,虽然可通过注入专门处理同步问题的服务解决,但是缓存数据的类型越多,则需要的服务也越多,组件注入过多的服务会造成严重耦合,还会出现组件多次更新相同的数据,造成性能损耗。为了解决上述问题,提出一种响应式的中间状态管理方法,使数据传输透明化,自动化同步数据。In related technologies, Angular, as one of the mainstream frameworks for front-end development, usually uses services to cache the intermediate data state, and then through dependency injection, the components that introduce the service can share the cached data and have permission to modify it, so it is easy to Causes components to tamper with cached data and cause errors that cannot be traced. After another component changes the cached data, it needs to synchronize the data to other components that reference the same service. Although it can be solved by injecting services that deal with synchronization problems, the more types of cached data, the more services are needed. Components injecting too many services will cause serious coupling, and components will update the same data multiple times, resulting in performance loss. In order to solve the above problems, a responsive intermediate state management method is proposed to make data transmission transparent and synchronize data automatically.
针对相关技术中存在的上述问题,目前尚未发现有效的解决方案。For the above problems existing in the related art, no effective solution has been found so far.
发明内容SUMMARY OF THE INVENTION
本发明实施例提供了一种数据更新的方法及装置、前端开发客户端。Embodiments of the present invention provide a data update method and device, and a front-end development client.
根据本发明的一个实施例,提供了一种数据更新的方法,包括:获取源数据的更新请求,其中,所述更新请求携带所述源数据和更新响应信息,所述更新响应信息用于指示所述源数据的更新类型;根据所述更新请求获取目标数据,并生成所述源数据的更新记录;向显示组件发送所述目标数据,以使所述显示组件使用所述目标数据更新所述源数据。According to an embodiment of the present invention, a data update method is provided, comprising: acquiring an update request for source data, wherein the update request carries the source data and update response information, and the update response information is used to indicate update type of the source data; acquire target data according to the update request, and generate an update record of the source data; send the target data to the display component, so that the display component uses the target data to update the source data.
可选的,获取源数据的更新请求包括以下之一:获取第一源数据的第一更新请求,所述第一更新请求携带所述第一源数据和第一更新响应信息,所述第一更新响应信息用于指示使用本地数据更新所述第一源数据;获取第二源数据的第二更新请求,所述第二更新请求携带所述第二源数据和第二更新响应信息,所述第二更新响应信息用于指示使用远程数据更新所述第一源数据。Optionally, the update request for acquiring source data includes one of the following: a first update request for acquiring first source data, the first update request carrying the first source data and first update response information, the first update request The update response information is used to instruct to use local data to update the first source data; obtain a second update request for the second source data, the second update request carries the second source data and the second update response information, the The second update response information is used to indicate that the first source data is updated using remote data.
可选的,根据所述更新请求获取目标数据,并生成所述源数据的更新记录,包括:在中间件解析所述更新请求,确定所述源数据的更新类型;在所述更新类型为远程更新时,所述中间件从所述源数据中获取更新参数,并根据所述更新参数向后端应用程序编程接口API请求查询目标数据;在所述目标数据请求成功时,所述中间件响应所述源数据中的回调函数,以使所述回调函数将所述目标数据从所述中间件传递至状态管理器,并生成所述源数据的更新记录,其中,所述更新记录包括:更新时间,所述源数据、所述目标数据。Optionally, acquiring target data according to the update request, and generating an update record of the source data, includes: parsing the update request in the middleware, and determining the update type of the source data; when the update type is remote When updating, the middleware obtains update parameters from the source data, and requests the back-end application programming interface API to query target data according to the update parameters; when the target data request is successful, the middleware responds A callback function in the source data, so that the callback function transmits the target data from the middleware to the state manager, and generates an update record of the source data, wherein the update record includes: update Time, the source data, the target data.
可选的,所述方法还包括:在所述目标数据请求失败时,在所述中间件生成错误信息,并将所述错误信息从所述中间件广播至已订阅的功能组件,其中,所述错误信息用于指示所述源数据更新失败。Optionally, the method further includes: when the target data request fails, generating error information in the middleware, and broadcasting the error information from the middleware to the subscribed functional components, wherein the The error message is used to indicate that the source data update fails.
可选的,根据所述更新请求获取目标数据,并生成所述源数据的更新记录,包括:在中间件解析所述更新请求,确定所述源数据的更新类型;在所述更新类型为直接更新时,将所述源数据通过所述中间件传输至状态管理器,所述状态管理器在本地根据源数据请求查询目标数据;在所述状态管理器使用所述目标数据更新所述源数据后,生成所述源数据的更新记录,其中,所述更新记录包括:更新时间,所述源数据、所述目标数据。Optionally, acquiring target data according to the update request, and generating an update record of the source data, includes: parsing the update request in the middleware, and determining the update type of the source data; when the update type is direct When updating, the source data is transmitted to the state manager through the middleware, and the state manager locally queries the target data according to the source data request; the state manager uses the target data to update the source data Then, an update record of the source data is generated, wherein the update record includes: update time, the source data, and the target data.
根据本发明的另一个实施例,提供了一种数据更新的装置,包括:获取模块,用于获取源数据的更新请求,其中,所述更新请求携带所述源数据和更新响应信息,所述更新响应信息用于指示所述源数据的更新类型;处理模块,用于根据所述更新请求获取目标数据,并生成所述源数据的更新记录;发送模块,用于向显示组件发送所述目标数据,以使所述显示组件使用所述目标数据更新所述源数据。According to another embodiment of the present invention, an apparatus for updating data is provided, comprising: an acquisition module configured to acquire an update request for source data, wherein the update request carries the source data and update response information, and the The update response information is used to indicate the update type of the source data; the processing module is used to obtain the target data according to the update request and generate an update record of the source data; the sending module is used to send the target data to the display component data to cause the display component to update the source data with the target data.
可选的,所述获取模块包括以下之一:第一获取单元,用于获取第一源数据的第一更新请求,所述第一更新请求携带所述第一源数据和第一更新响应信息,所述第一更新响应信息用于指示使用本地数据更新所述第一源数据;第二获取单元,用于获取第二源数据的第二更新请求,所述第二更新请求携带所述第二源数据和第二更新响应信息,所述第二更新响应信息用于指示使用远程数据更新所述第一源数据。Optionally, the obtaining module includes one of the following: a first obtaining unit, configured to obtain a first update request of the first source data, where the first update request carries the first source data and the first update response information , the first update response information is used to instruct the use of local data to update the first source data; the second acquisition unit is used to acquire a second update request of the second source data, where the second update request carries the first update request. Second source data and second update response information, where the second update response information is used to instruct to use remote data to update the first source data.
可选的,所述处理模块包括:确定单元,用于在中间件解析所述更新请求,确定所述源数据的更新类型;第一处理单元,用于在所述更新类型为远程更新时,所述中间件从所述源数据中获取更新参数,并根据所述更新参数向后端应用程序编程接口API请求查询目标数据;第一记录单元,用于在所述目标数据请求成功时,所述中间件响应所述源数据中的回调函数,以使所述回调函数将所述目标数据从所述中间件传递至状态管理器,并生成所述源数据的更新记录,其中,所述更新记录包括:更新时间,所述源数据、所述目标数据。Optionally, the processing module includes: a determining unit, configured to parse the update request in the middleware, and determine the update type of the source data; a first processing unit, configured to, when the update type is remote update, The middleware obtains update parameters from the source data, and requests the back-end application programming interface API to query target data according to the update parameters; the first recording unit is used to record the target data when the target data request is successful. The middleware responds to the callback function in the source data, so that the callback function transfers the target data from the middleware to the state manager, and generates an update record of the source data, wherein the update The record includes: update time, the source data, and the target data.
可选的,所述处理模块还包括:广播单元,用于在所述目标数据请求失败时,在所述中间件生成错误信息,并将所述错误信息从所述中间件广播至已订阅的功能组件,其中,所述错误信息用于指示所述源数据更新失败。Optionally, the processing module further includes: a broadcasting unit, configured to generate error information in the middleware when the target data request fails, and broadcast the error information from the middleware to subscribed users. The functional component, wherein the error information is used to indicate that the source data update fails.
可选的,所述处理模块包括:确定单元,用于在中间件解析所述更新请求,确定所述源数据的更新类型;第二处理单元,用于在所述更新类型为直接更新时,将所述源数据通过所述中间件传输至状态管理器,所述状态管理器在本地根据源数据请求查询目标数据;第二记录单元,用于在所述状态管理器使用所述目标数据更新所述源数据后,生成所述源数据的更新记录,其中,所述更新记录包括:更新时间,所述源数据、所述目标数据。Optionally, the processing module includes: a determination unit, configured to parse the update request in the middleware, and determine the update type of the source data; a second processing unit, configured to, when the update type is direct update, The source data is transmitted to the state manager through the middleware, and the state manager locally queries the target data according to the source data request; a second recording unit is used to update the state manager using the target data After the source data is obtained, an update record of the source data is generated, wherein the update record includes: update time, the source data, and the target data.
根据本发明的另一个实施例,提供了一种前端开发客户端,包括:功能组件、显示组件,状态管理器,中间件,其中,所述中间件包括如上实施例所述的装置。According to another embodiment of the present invention, a front-end development client is provided, including: a functional component, a display component, a state manager, and a middleware, wherein the middleware includes the apparatus described in the above embodiment.
根据本发明的又一个实施例,还提供了一种存储介质,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时执行上述任一项方法实施例中的步骤。According to yet another embodiment of the present invention, a storage medium is also provided, wherein a computer program is stored in the storage medium, wherein the computer program is configured to execute the steps in any one of the above method embodiments when running.
根据本发明的又一个实施例,还提供了一种电子装置,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行上述任一项方法实施例中的步骤。According to yet another embodiment of the present invention, there is also provided an electronic device comprising a memory and a processor, wherein the memory stores a computer program, the processor is configured to run the computer program to execute any of the above Steps in Method Examples.
通过本发明,获取源数据的更新请求,然后根据所述更新请求获取目标数据,并生成所述源数据的更新记录,最后向显示组件发送所述目标数据,以使所述显示组件使用所述目标数据更新所述源数据,通过生成更新过程的更新记录并主动向显示组件发送需要更新的目标数据,解决了相关技术在更新数据时容易造成组件与服务耦合的技术问题,可以使组件减少注入服务数量,避免组件与服务耦合,还可以避免组件多次更新相同的数据,降低了软件系统的性能损耗。According to the present invention, the update request of the source data is obtained, then the target data is obtained according to the update request, the update record of the source data is generated, and finally the target data is sent to the display component, so that the display component uses the The target data updates the source data. By generating the update record of the update process and actively sending the target data to be updated to the display component, the technical problem that the related technology is likely to cause the coupling of the component and the service when updating the data is solved, and the injection of the component can be reduced. The number of services can avoid the coupling between components and services, and it can also prevent components from updating the same data multiple times, reducing the performance loss of the software system.
附图说明Description of drawings
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The accompanying drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the attached image:
图1是本发明实施例的一种数据更新的计算机的结构框图;1 is a structural block diagram of a computer for data updating according to an embodiment of the present invention;
图2是根据本发明实施例的一种数据更新的方法流程图;2 is a flowchart of a method for updating data according to an embodiment of the present invention;
图3是本发明实施例数据更新的交互示意图;3 is an interactive schematic diagram of data update according to an embodiment of the present invention;
图4是本发明实施例的一种数据更新的装置的结构框图;4 is a structural block diagram of an apparatus for data updating according to an embodiment of the present invention;
图5是本发明实施例的一种前端开发客户端的连接图。FIG. 5 is a connection diagram of a front-end development client according to an embodiment of the present invention.
具体实施方式Detailed ways
下文中将参考附图并结合实施例来详细说明本发明。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。Hereinafter, the present invention will be described in detail with reference to the accompanying drawings and in conjunction with embodiments. It should be noted that the embodiments in the present application and the features of the embodiments may be combined with each other in the case of no conflict.
需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。It should be noted that the terms "first", "second" and the like in the description and claims of the present invention and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific sequence or sequence.
实施例1Example 1
本申请实施例一所提供的方法实施例可以在计算机、前端开发客户端、中间件、前端开发设备等类似的运算装置中执行。以运行在计算机上为例,图1是本发明实施例的一种数据更新的计算机的结构框图,如图1所示,计算机10可以包括一个或多个(图1中仅示出一个)处理器102(处理器102可以包括但不限于微处理器MCU或可编程逻辑器件FPGA等的处理装置)和用于存储数据的存储器104,可选地,上述计算机还可以包括用于通信功能的传输设备106以及输入输出设备108。本领域普通技术人员可以理解,图1所示的结构仅为示意,其并不对上述计算机的结构造成限定。例如,计算机10还可包括比图1中所示更多或者更少的组件,或者具有与图1所示不同的配置。The method embodiment provided in the first embodiment of the present application may be executed in a computer, a front-end development client, middleware, a front-end development device, and other similar computing devices. Taking running on a computer as an example, FIG. 1 is a structural block diagram of a computer for data updating according to an embodiment of the present invention. As shown in FIG. 1 , the computer 10 may include one or more (only one is shown in FIG. 1 ) processing A processor 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA, etc.) and a
存储器104可用于存储计算机程序,例如,应用软件的软件程序以及模块,如本发明实施例中的一种数据更新的控制方法对应的计算机程序,处理器102通过运行存储在存储器104内的计算机程序,从而执行各种功能应用以及数据处理,即实现上述的方法。存储器104可包括高速随机存储器,还可包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器104可进一步包括相对于处理器102远程设置的存储器,这些远程存储器可以通过网络连接至计算机10。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The
传输装置106用于经由一个网络接收或者发送数据。上述的网络具体实例可包括计算机10的通信供应商提供的无线网络。在一个实例中,传输装置106包括一个网络适配器(Network Interface Controller,简称为NIC),其可通过基站与其他网络设备相连从而可与互联网进行通讯。在一个实例中,传输装置106可以为射频(Radio Frequency,简称为RF)模块,其用于通过无线方式与互联网进行通讯。Transmission means 106 are used to receive or transmit data via a network. The specific example of the above-mentioned network may include a wireless network provided by the communication provider of the computer 10 . In one example, the
在本实施例中提供了一种数据更新的方法,图2是根据本发明实施例的一种数据更新的方法流程图,如图2所示,该流程包括如下步骤:A method for updating data is provided in this embodiment, and FIG. 2 is a flowchart of a method for updating data according to an embodiment of the present invention. As shown in FIG. 2 , the process includes the following steps:
步骤S202,获取源数据的更新请求,其中,更新请求携带源数据和更新响应信息,更新响应信息用于指示源数据的更新类型;Step S202, obtaining an update request of the source data, wherein the update request carries the source data and update response information, and the update response information is used to indicate the update type of the source data;
本实施例中,可以通过检测显示组件的用户操作来获取更新请求。In this embodiment, the update request can be acquired by detecting the user operation of the display component.
步骤S204,根据更新请求获取目标数据,并生成源数据的更新记录;Step S204, obtaining target data according to the update request, and generating an update record of the source data;
本实施例的更新记录用于记录和存储源数据的更新过程,在某个对象被更新多次时,可以通过时间轴的方式来记录。The update record in this embodiment is used to record and store the update process of the source data. When an object is updated for many times, it can be recorded by means of a time axis.
步骤S206,向显示组件发送目标数据,以使显示组件使用目标数据更新源数据。Step S206, sending the target data to the display component, so that the display component uses the target data to update the source data.
可选的,可以通过功能组件来发送目标数据,先将目标数据发送给功能组件,然后功能组件传递至显示组件。Optionally, the target data can be sent through the functional component, the target data is first sent to the functional component, and then the functional component is transmitted to the display component.
通过上述步骤,获取源数据的更新请求,然后根据所述更新请求获取目标数据,并生成所述源数据的更新记录,最后向显示组件发送所述目标数据,以使所述显示组件使用所述目标数据更新所述源数据,通过生成更新过程的更新记录并主动向显示组件发送需要更新的目标数据,解决了相关技术在更新数据时容易造成组件与服务耦合的技术问题,可以使组件减少注入服务数量,避免组件与服务耦合,还可以避免组件多次更新相同的数据,降低了软件系统的性能损耗。Through the above steps, the update request of the source data is obtained, then the target data is obtained according to the update request, the update record of the source data is generated, and finally the target data is sent to the display component, so that the display component uses the The target data updates the source data. By generating the update record of the update process and actively sending the target data to be updated to the display component, the technical problem that the related technology is likely to cause the coupling of the component and the service when updating the data is solved, and the injection of the component can be reduced. The number of services can avoid the coupling between components and services, and it can also prevent components from updating the same data multiple times, reducing the performance loss of the software system.
在本实施例中,获取源数据的更新请求可以但不限于为:In this embodiment, the update request for obtaining source data may be, but is not limited to:
获取第一源数据的第一更新请求,第一更新请求携带第一源数据和第一更新响应信息,第一更新响应信息用于指示使用本地数据更新第一源数据;第一源数据为实体对象,符号等数据。该更新类型直接将本地的更新数据覆盖原来数据(源数据)。Obtain the first update request for the first source data. The first update request carries the first source data and the first update response information. The first update response information is used to instruct the use of local data to update the first source data; the first source data is an entity Data such as objects, symbols, etc. This update type directly overwrites the original data (source data) with the local update data.
获取第二源数据的第二更新请求,第二更新请求携带第二源数据和第二更新响应信息,第二更新响应信息用于指示使用远程数据更新第一源数据。第二源数据为带有回调的函数,回调函数中响应其他具体动作,实现数据更新。该更新类型从后端API中远程获取待更新数据(目标数据)。Obtain a second update request for the second source data, where the second update request carries the second source data and second update response information, where the second update response information is used to instruct the use of remote data to update the first source data. The second source data is a function with a callback, and the callback function responds to other specific actions to realize data update. This update type remotely obtains the data to be updated (target data) from the backend API.
本实施例可以通过多种方式获取目标数据,根据更新类型的不同,在设备内部调取的组件不同,下面进行详细说明:In this embodiment, the target data can be acquired in various ways. According to the different update types, the components fetched inside the device are different. The following is a detailed description:
在本实施例的一个实施方式中,根据更新请求获取目标数据,并生成源数据的更新记录,包括:In an implementation of this embodiment, the target data is acquired according to the update request, and the update record of the source data is generated, including:
S11,在中间件解析更新请求,确定源数据的更新类型;S11, parse the update request in the middleware, and determine the update type of the source data;
S12,在更新类型为远程更新时,中间件从源数据中获取更新参数,并根据更新参数向后端应用程序编程接口API请求查询目标数据;S12, when the update type is remote update, the middleware obtains update parameters from the source data, and requests the back-end application programming interface API to query the target data according to the update parameters;
S13,在目标数据请求成功时,中间件响应源数据中的回调函数,以使回调函数将目标数据从中间件传递至状态管理器,并生成源数据的更新记录,其中,更新记录包括:更新时间,源数据、目标数据。S13, when the target data request is successful, the middleware responds to the callback function in the source data, so that the callback function transfers the target data from the middleware to the state manager, and generates an update record of the source data, wherein the update record includes: update time, source data, target data.
可选的,在本实施方式的另一方面,在目标数据请求失败时,在中间件生成错误信息,并将错误信息从中间件广播至已订阅的功能组件,其中,错误信息用于指示源数据更新失败。Optionally, in another aspect of this embodiment, when the target data request fails, the middleware generates error information, and broadcasts the error information from the middleware to the subscribed functional components, wherein the error information is used to indicate the source Data update failed.
在本实施例的另一个实施方式中,根据更新请求获取目标数据,并生成源数据的更新记录,包括:In another implementation of this embodiment, the target data is acquired according to the update request, and an update record of the source data is generated, including:
S21,在中间件解析更新请求,确定源数据的更新类型;S21, parse the update request in the middleware, and determine the update type of the source data;
S21,在更新类型为直接更新时,将源数据通过中间件传输至状态管理器,状态管理器在本地根据源数据请求查询目标数据;S21, when the update type is direct update, the source data is transmitted to the state manager through the middleware, and the state manager locally queries the target data according to the source data request;
S23,在所述状态管理器使用所述目标数据更新所述源数据后,生成源数据的更新记录,其中,更新记录包括:更新时间,源数据、目标数据。S23. After the state manager uses the target data to update the source data, an update record of the source data is generated, wherein the update record includes: update time, source data, and target data.
图3是本发明实施例数据更新的交互示意图,交互对象包括同一客户端内的显示组件,功能组件,中间件,状态管理器,交互流程包括:3 is a schematic diagram of interaction of data update according to an embodiment of the present invention. The interaction objects include display components, functional components, middleware, and state managers in the same client. The interaction process includes:
S1、用户通过在显示组件中的操作,如点击按钮等,提交待更新数据(源数据)以及响应动作至中间件(如步骤①),响应动作可分为以下两种类型:S1. The user submits the data to be updated (source data) and the response action to the middleware (such as step ①) through the operation in the display component, such as clicking the button, etc. The response action can be divided into the following two types:
1)直接更新,即直接将更新数据(目标数据)覆盖原来数据,待更新数据通常为实体对象;1) Direct update, that is, the update data (target data) is directly overwritten with the original data, and the data to be updated is usually an entity object;
2)远程更新,从后端API中获取其他待更新数据,待更新数据通常为带有回调的函数,回调函数中响应其他具体动作,更新待更新数据;2) Remote update, obtain other data to be updated from the back-end API, the data to be updated is usually a function with a callback, and the callback function responds to other specific actions to update the data to be updated;
S2、中间件接收待更新数据后,通过响应动作判断是直接更新还是远程更新。S2. After receiving the data to be updated, the middleware determines whether to update directly or remotely through a response action.
直接更新则将待更新数据传输至状态管理(如步骤②),状态管理更新相应数据(如步骤③),记录更新过程;远程更新则中间件通知状态管理更新动作开始字段(如步骤②③),从待更新数据中获取参数,向后端API获取数据(如步骤④),数据返回(如步骤⑤)。如果请求成功,则响应待更新数据中的回调函数,回调函数将获取的数据传递至状态管理更新,并更新动作结束字段(如步骤②③)。如果请求失败,则将错误信息返回至功能组件,由功能组件进行异常处理(如步骤⑦),记录更新过程。For direct update, the data to be updated is transmitted to the state management (such as step ②), the state management updates the corresponding data (such as step ③), and the update process is recorded; for remote update, the middleware notifies the state management update action start field (such as step ②③), Obtain parameters from the data to be updated, obtain data from the back-end API (such as step ④), and return the data (such as step ⑤). If the request is successful, it responds to the callback function in the data to be updated, the callback function transfers the acquired data to the state management update, and updates the action end field (such as step ②③). If the request fails, the error information is returned to the functional component, and the functional component performs exception handling (such as step ⑦), and records the update process.
S3、状态管理提供所有缓存数据的可观察对象,中间件提供请求失败的可观察对象,功能组件分别进行订阅,用来接收更新数据和请求错误信息。由于状态管理和中间件是通过广播形式通知数据更新,所有订阅的组件获得的缓存数据都是相同的,并且都为同步响应。功能组件将接收数据传递至显示组件,视图将同步更新。功能组件还可以对请求失败的数据进行异常处理,避免数据的不正常更新。所有过程均可在附加功能记录中获取,了解数据传输过程。S3. State management provides observable objects for all cached data, middleware provides observable objects for failed requests, and functional components subscribe respectively to receive updated data and request error information. Since state management and middleware notify data updates through broadcast, the cached data obtained by all subscribed components is the same, and they all respond synchronously. The functional component will pass the received data to the display component, and the view will be updated synchronously. The functional component can also perform abnormal processing on the data that the request fails to avoid abnormal updating of the data. All processes are available in the additional function record for the data transfer process.
在客户端环境下,因为大部分的请求接口都是异步进行的,需要保证获取数据的返回顺序和正确性,从架构图可知,后端服务器从数据库中获取内容返回至中间件。本实施例的中间件的功能包括:记录数据返回的顺序,每个接口返回的顺序是通过日志记录的,形成时间轴;验证数据的正确性,数据格式正确则返回至下一单元,格式错误则将其过滤,并返回统一格式的错误提示信息给组件,保证客户端页面显示正常。将需要缓存的数据传至状态管理器,组件通过订阅状态管理器,监测到数据更新后,状态管理器将进行广播,向所有订阅的组件传递更新数据。In the client-side environment, because most of the request interfaces are performed asynchronously, it is necessary to ensure the return order and correctness of the acquired data. From the architecture diagram, we can see that the back-end server retrieves the content from the database and returns it to the middleware. The functions of the middleware in this embodiment include: recording the sequence of data return, and the sequence returned by each interface is recorded through a log to form a time axis; verifying the correctness of the data, and returning to the next unit if the data format is correct, if the format is incorrect Then filter it and return the error message in a unified format to the component to ensure that the client page is displayed normally. Send the data that needs to be cached to the state manager. The component subscribes to the state manager. After monitoring the data update, the state manager will broadcast and deliver the updated data to all subscribed components.
本实施例通过引入中间件,在组件与状态管理器之间进行动作响应和数据处理,并且提供日志管理等附加功能,对数据更新进行跟踪。对组件修改缓存数据的方式进行管理,并且提供跟踪,使数据传输透明化,组件更新数据,自动同步更新至引入相同缓存数据的组件。In this embodiment, by introducing middleware, action response and data processing are performed between the component and the state manager, and additional functions such as log management are provided to track data updates. Manage the way components modify cached data, and provide tracking to make data transmission transparent, components update data, and automatically synchronize updates to components that introduce the same cached data.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到根据上述实施例的方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本发明各个实施例所述的方法。From the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is better implementation. Based on this understanding, the technical solutions of the present invention can be embodied in the form of software products in essence or the parts that make contributions to the prior art, and the computer software products are stored in a storage medium (such as ROM/RAM, magnetic disk, CD-ROM), including several instructions to make a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention.
实施例2Example 2
在本实施例中还提供了一种数据更新的装置,前端开发客户端,用于实现上述实施例及优选实施方式,已经进行过说明的不再赘述。如以下所使用的,术语“模块”可以实现预定功能的软件和/或硬件的组合。尽管以下实施例所描述的装置较佳地以软件来实现,但是硬件,或者软件和硬件的组合的实现也是可能并被构想的。In this embodiment, a data update apparatus, a front-end development client, is also provided, which is used to implement the above-mentioned embodiments and preferred implementations, and what has been described will not be repeated. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, implementations in hardware, or a combination of software and hardware, are also possible and contemplated.
实施例提供了一种数据更新的装置,图4是本发明实施例的一种数据更新的装置的结构框图,该装置包括:获取模块40,处理模块42,发送模块44,其中。The embodiment provides an apparatus for updating data. FIG. 4 is a structural block diagram of an apparatus for updating data according to an embodiment of the present invention. The apparatus includes: an acquisition module 40 , a processing module 42 , and a sending module 44 .
获取模块40,用于获取源数据的更新请求,其中,所述更新请求携带所述源数据和更新响应信息,所述更新响应信息用于指示所述源数据的更新类型;an obtaining module 40, configured to obtain an update request of the source data, wherein the update request carries the source data and update response information, and the update response information is used to indicate the update type of the source data;
处理模块42,用于根据所述更新请求获取目标数据,并生成所述源数据的更新记录;a processing module 42, configured to obtain target data according to the update request, and generate an update record of the source data;
发送模块44,用于向显示组件发送所述目标数据,以使所述显示组件使用所述目标数据更新所述源数据。The sending module 44 is configured to send the target data to the display component, so that the display component uses the target data to update the source data.
可选的,可选的,所述获取模块包括以下之一:第一获取单元,用于获取第一源数据的第一更新请求,所述第一更新请求携带所述第一源数据和第一更新响应信息,所述第一更新响应信息用于指示使用本地数据更新所述第一源数据;第二获取单元,用于获取第二源数据的第二更新请求,所述第二更新请求携带所述第二源数据和第二更新响应信息,所述第二更新响应信息用于指示使用远程数据更新所述第一源数据。Optionally, optionally, the obtaining module includes one of the following: a first obtaining unit, configured to obtain a first update request of the first source data, where the first update request carries the first source data and the first update request. an update response information, the first update response information is used to instruct the use of local data to update the first source data; a second acquisition unit is used to acquire a second update request for the second source data, the second update request Carrying the second source data and second update response information, where the second update response information is used to instruct to use remote data to update the first source data.
可选的,所述处理模块包括:确定单元,用于在中间件解析所述更新请求,确定所述源数据的更新类型;第一处理单元,用于在所述更新类型为远程更新时,所述中间件从所述源数据中获取更新参数,并根据所述更新参数向后端应用程序编程接口API请求查询目标数据;第一记录单元,用于在所述目标数据请求成功时,所述中间件响应所述源数据中的回调函数,以使所述回调函数将所述目标数据从所述中间件传递至状态管理器,并生成所述源数据的更新记录,其中,所述更新记录包括:更新时间,所述源数据、所述目标数据。Optionally, the processing module includes: a determining unit, configured to parse the update request in the middleware, and determine the update type of the source data; a first processing unit, configured to, when the update type is remote update, The middleware obtains update parameters from the source data, and requests the back-end application programming interface API to query target data according to the update parameters; the first recording unit is used to record the target data when the target data request is successful. The middleware responds to the callback function in the source data, so that the callback function transfers the target data from the middleware to the state manager, and generates an update record of the source data, wherein the update The record includes: update time, the source data, and the target data.
可选的,所述处理模块还包括:广播单元,用于在所述目标数据请求失败时,在所述中间件生成错误信息,并将所述错误信息从所述中间件广播至已订阅的功能组件,其中,所述错误信息用于指示所述源数据更新失败。Optionally, the processing module further includes: a broadcasting unit, configured to generate error information in the middleware when the target data request fails, and broadcast the error information from the middleware to subscribed users. The functional component, wherein the error information is used to indicate that the source data update fails.
可选的,所述处理模块包括:确定单元,用于在中间件解析所述更新请求,确定所述源数据的更新类型;第二处理单元,用于在所述更新类型为直接更新时,将所述源数据通过所述中间件传输至状态管理器,所述状态管理器在本地根据源数据请求查询目标数据;第二记录单元,用于在所述状态管理器使用所述目标数据更新所述源数据后,生成所述源数据的更新记录,其中,所述更新记录包括:更新时间,所述源数据、所述目标数据。Optionally, the processing module includes: a determination unit, configured to parse the update request in the middleware, and determine the update type of the source data; a second processing unit, configured to, when the update type is direct update, The source data is transmitted to the state manager through the middleware, and the state manager locally queries the target data according to the source data request; a second recording unit is used to update the state manager using the target data After the source data is obtained, an update record of the source data is generated, wherein the update record includes: update time, the source data, and the target data.
实施例还提供了一种前端开发客户端,图5是本发明实施例的一种前端开发客户端的连接图,至少包括:功能组件50、显示组件52,状态管理器54,中间件56,其中,所述中间件包括如上述实施例所述的装置。The embodiment also provides a front-end development client. FIG. 5 is a connection diagram of a front-end development client according to an embodiment of the present invention, which at least includes: a functional component 50, a display component 52, a state manager 54, and a middleware 56, wherein , the middleware includes the device described in the above embodiment.
需要说明的是,上述各个模块是可以通过软件或硬件来实现的,对于后者,可以通过以下方式实现,但不限于此:上述模块均位于同一处理器中;或者,上述各个模块以任意组合的形式分别位于不同的处理器中。It should be noted that the above modules can be implemented by software or hardware, and the latter can be implemented in the following ways, but not limited to this: the above modules are all located in the same processor; or, the above modules can be combined in any combination The forms are located in different processors.
实施例3Example 3
本发明的实施例还提供了一种存储介质,该存储介质中存储有计算机程序,其中,该计算机程序被设置为运行时执行上述任一项方法实施例中的步骤。An embodiment of the present invention further provides a storage medium, where a computer program is stored in the storage medium, wherein the computer program is configured to execute the steps in any one of the above method embodiments when running.
可选地,在本实施例的一个方面中,上述存储介质可以被设置为存储用于执行以下步骤的计算机程序:Optionally, in an aspect of this embodiment, the above-mentioned storage medium may be configured to store a computer program for performing the following steps:
S1,获取源数据的更新请求,其中,所述更新请求携带所述源数据和更新响应信息,所述更新响应信息用于指示所述源数据的更新类型;S1. Obtain an update request for source data, wherein the update request carries the source data and update response information, where the update response information is used to indicate the update type of the source data;
S2,根据所述更新请求获取目标数据,并生成所述源数据的更新记录;S2, acquire target data according to the update request, and generate an update record of the source data;
S3,向显示组件发送所述目标数据,以使所述显示组件使用所述目标数据更新所述源数据。S3: Send the target data to the display component, so that the display component updates the source data using the target data.
可选地,在本实施例中,上述存储介质可以包括但不限于:U盘、只读存储器(Read-Only Memory,简称为ROM)、随机存取存储器(Random Access Memory,简称为RAM)、移动硬盘、磁碟或者光盘等各种可以存储计算机程序的介质。Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (Read-Only Memory, referred to as ROM), a random access memory (Random Access Memory, referred to as RAM), Various media that can store computer programs, such as removable hard disks, magnetic disks, or optical disks.
本发明的实施例还提供了一种电子装置,包括存储器和处理器,该存储器中存储有计算机程序,该处理器被设置为运行计算机程序以执行上述任一项方法实施例中的步骤。An embodiment of the present invention also provides an electronic device, comprising a memory and a processor, where a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any of the above method embodiments.
可选地,上述电子装置还可以包括传输设备以及输入输出设备,其中,该传输设备和上述处理器连接,该输入输出设备和上述处理器连接。Optionally, the above-mentioned electronic device may further include a transmission device and an input-output device, wherein the transmission device is connected to the above-mentioned processor, and the input-output device is connected to the above-mentioned processor.
可选地,在本实施例的一个方面中,上述处理器可以被设置为通过计算机程序执行以下步骤:Optionally, in an aspect of this embodiment, the above-mentioned processor may be configured to execute the following steps through a computer program:
S1,获取源数据的更新请求,其中,所述更新请求携带所述源数据和更新响应信息,所述更新响应信息用于指示所述源数据的更新类型;S1. Obtain an update request for source data, wherein the update request carries the source data and update response information, where the update response information is used to indicate the update type of the source data;
S2,根据所述更新请求获取目标数据,并生成所述源数据的更新记录;S2, acquire target data according to the update request, and generate an update record of the source data;
S3,向显示组件发送所述目标数据,以使所述显示组件使用所述目标数据更新所述源数据。S3: Send the target data to the display component, so that the display component updates the source data using the target data.
可选地,本实施例中的具体示例可以参考上述实施例及可选实施方式中所描述的示例,本实施例在此不再赘述。Optionally, for specific examples in this embodiment, reference may be made to the examples described in the foregoing embodiments and optional implementation manners, and details are not described herein again in this embodiment.
显然,本领域的技术人员应该明白,上述的本发明的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本发明不限制于任何特定的硬件和软件结合。Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the present invention can be implemented by a general-purpose computing device, which can be centralized on a single computing device, or distributed in a network composed of multiple computing devices Alternatively, they may be implemented in program code executable by a computing device, such that they may be stored in a storage device and executed by the computing device, and in some cases, in a different order than here The steps shown or described are performed either by fabricating them separately into individual integrated circuit modules, or by fabricating multiple modules or steps of them into a single integrated circuit module. As such, the present invention is not limited to any particular combination of hardware and software.
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included within the protection scope of the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910818052.2A CN110659299B (en) | 2019-08-30 | 2019-08-30 | Data update method and device, front-end development client |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910818052.2A CN110659299B (en) | 2019-08-30 | 2019-08-30 | Data update method and device, front-end development client |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN110659299A CN110659299A (en) | 2020-01-07 |
| CN110659299B true CN110659299B (en) | 2020-11-10 |
Family
ID=69036630
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201910818052.2A Withdrawn - After Issue CN110659299B (en) | 2019-08-30 | 2019-08-30 | Data update method and device, front-end development client |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN110659299B (en) |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113242169B (en) * | 2021-05-10 | 2023-05-30 | 广东拓斯达科技股份有限公司 | Multi-slave data updating method, system, equipment and storage medium |
Family Cites Families (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20070100844A1 (en) * | 2005-10-28 | 2007-05-03 | International Business Machines Corporation | System and method for dynamically updating web pages using messaging-oriented middleware |
| CN103390041B (en) * | 2013-07-18 | 2016-05-04 | 杭州东信北邮信息技术有限公司 | A kind of method and system that data, services is provided based on middleware |
| CN103678632A (en) * | 2013-12-19 | 2014-03-26 | 成都市卓睿科技有限公司 | System and method for updating data fast in data system |
| CN105335170A (en) * | 2014-06-05 | 2016-02-17 | 阿里巴巴集团控股有限公司 | Distributed system and incremental data updating method |
| CN106657174B (en) * | 2015-10-28 | 2020-11-03 | 阿里巴巴集团控股有限公司 | Data synchronization method, data updating method and data updating device |
| CN105677250B (en) * | 2016-01-04 | 2019-07-12 | 北京百度网讯科技有限公司 | The update method and updating device of object data in object storage system |
| CN105787077B (en) * | 2016-03-02 | 2020-05-15 | 百度在线网络技术(北京)有限公司 | Data synchronization method and device |
| CN109586948A (en) * | 2018-10-16 | 2019-04-05 | 深圳壹账通智能科技有限公司 | Update method, apparatus, computer equipment and the storage medium of system configuration data |
| CN109634599B (en) * | 2018-12-14 | 2020-05-19 | 北京字节跳动网络技术有限公司 | Page view display method, device, equipment and storage medium |
-
2019
- 2019-08-30 CN CN201910818052.2A patent/CN110659299B/en not_active Withdrawn - After Issue
Also Published As
| Publication number | Publication date |
|---|---|
| CN110659299A (en) | 2020-01-07 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN107943951B (en) | A method and system for retrieving blockchain business information | |
| CN111177161B (en) | Data processing method, device, computing equipment and storage medium | |
| CN107295080A (en) | Date storage method and server applied to distributed server cluster | |
| US11838381B2 (en) | Device cross-area access method, electronic device, and non-transitory computer-readable storage medium | |
| US20200175549A1 (en) | Advertisement Display Control Method, Terminal, and Advertisement Server | |
| CN111008032B (en) | A method and device for updating page data | |
| JP2019506764A (en) | System and method for obtaining, processing and updating global information | |
| US12363068B2 (en) | Method and apparatus for configuring network line, and method for scheduling network request | |
| CN119356987A (en) | Device status monitoring method, device, device and storage medium | |
| CN110659299B (en) | Data update method and device, front-end development client | |
| US20220150348A1 (en) | Method for Service Decision Distribution Among Multiple Terminal Devices and System | |
| CN113238815A (en) | Interface access control method, device, equipment and storage medium | |
| US20110093509A1 (en) | Common interaction log repository with advanced content management capabilities | |
| CN110858201A (en) | Data processing method and system, processor and storage medium | |
| CN111190625A (en) | APP version upgrading method, server, client and computer readable storage medium | |
| CN112650815B (en) | Method and device for synchronizing environment data, storage medium and electronic device | |
| US9374437B2 (en) | Schema validation proxy | |
| CN119544702A (en) | Log data processing method, system and computer device | |
| US10067808B2 (en) | Nondeterministic operation execution environment utilizing resource registry | |
| CN111400266B (en) | Data processing method and system, and diagnosis processing method and device for operation event | |
| WO2021115485A1 (en) | Epg data management method, server, and readable storage medium | |
| CN117874033A (en) | Database sub-table method and device, electronic equipment and storage medium | |
| CN108805741B (en) | Fusion method, device and system of power quality data | |
| CN114969159B (en) | Data query method, data query device, computer equipment and medium | |
| CN114285743B (en) | Method, device, electronic equipment and storage medium for updating configuration information |
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 | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| AV01 | Patent right actively abandoned |
Granted publication date: 20201110 Effective date of abandoning: 20251215 |
|
| AV01 | Patent right actively abandoned |
Granted publication date: 20201110 Effective date of abandoning: 20251215 |
|
| AV01 | Patent right actively abandoned | ||
| AV01 | Patent right actively abandoned |