CN-122027614-A - Data communication method, device, terminal and storage medium
Abstract
The application provides a data communication method, a device, a terminal and a storage medium, wherein the method comprises the steps of initializing an event processing center instance in an operation frame bearing a plurality of atomization services, disposing a data communication mechanism in the event processing center instance, transmitting the event processing center instance to the inside of the atomization service when the atomization service is loaded on a browser page, and carrying out data communication with a target atomization service based on the data communication mechanism if the atomization service calls the event processing center instance. According to the application, the event processing center instance is initialized in the operation frame carrying a plurality of atomization services, and the data transmission between the atomization services is carried out based on the initialization event processing center instance, so that a large amount of server resources are not consumed or the local cache volume of the browser is occupied, and the convenience and efficiency of the data transmission between the atomization services are improved.
Inventors
- LI RUNBING
Assignees
- 深圳开鸿数字产业发展有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20251212
Claims (10)
- 1. A method of data communication, the method comprising: initializing an event processing center instance in an operation framework carrying a plurality of atomization services, wherein a data communication mechanism is deployed in the event processing center instance; when the atomization service is loaded to the browser page, the event processing center instance is transmitted to the inside of the atomization service; and if the atomization service calls the event processing center instance, carrying out data communication with the target atomization service based on the data communication mechanism.
- 2. The method according to claim 1, wherein the event processing center instance comprises a service mapping table; when the atomization service is loaded to the browser page, the event processing center instance is transferred to the inside of the atomization service, and the method comprises the following steps: when an atomization service is loaded to a browser page, receiving a service identifier and a callback function which are transmitted by the atomization service; and if the service identifier does not exist in the service mapping table, adding the service identifier into the service mapping table, and storing the corresponding relation between the callback function and the service identifier.
- 3. The data communication method according to claim 2, wherein when an atomized service is loaded on a browser page, after receiving a service identifier and a callback function that are input by the atomized service, the method further comprises: If the service identifier exists in the service mapping table, searching whether the callback function exists in a callback function set corresponding to the service identifier; And if not, storing the corresponding relation between the callback function and the service identifier.
- 4. The data communication method according to claim 2, wherein the event processing center instance further comprises an event storage queue; If the atomization service calls the event processing center instance, carrying out data communication with a target atomization service based on the data communication mechanism, wherein the method comprises the following steps: Receiving a distribution event transmitted by an atomization service, wherein the distribution event comprises a target service identifier and update data; And transmitting the updated data as parameters into the target callback function corresponding to the target service identifier and executing the target callback function.
- 5. The data communication method according to claim 4, wherein the step of inputting the update data as a parameter and executing the target callback function corresponding to the target service identification comprises: Storing the distributed event in the event storage queue; Traversing the event storage queue, integrating all the distributed events sent to the same target service identifier, and generating an integrated event; And according to the integration event, the updated data is used as a parameter to be transmitted in and a target callback function corresponding to the target service identifier is executed.
- 6. The data communication method according to claim 5, wherein the step of entering and executing the target callback function corresponding to the target service identification with the update data as a parameter according to the integration event comprises: When executing the next micro task, traversing the integration event in the event storage queue, and searching a target callback function corresponding to a target service identifier in the integration event; The updated data in the integration event is taken as parameters to be transmitted into and the target callback function is executed; and after the execution is finished, removing the integrated event from the event storage queue.
- 7. The data communication method according to claim 2, characterized in that the method further comprises: Receiving unbinding information transmitted by an atomization service; If the unbinding information comprises the service identifier to be unbinding and the callback function to be unbinding, removing the callback function to be unbinding from a callback function set corresponding to the service identifier to be unbinding in the service mapping table; and if the unbinding information only comprises the service identifier to be unbinding, removing all callback functions corresponding to the service identifier to be unbinding in the service mapping table.
- 8. A data communication apparatus, the apparatus comprising: The system comprises an initialization module, a data communication module and a data communication module, wherein the initialization module is used for initializing an event processing center instance in an operation frame carrying a plurality of atomization services, and the event processing center instance is provided with a data communication mechanism; The transmission module is used for transmitting the event processing center instance to the inside of the atomization service when the atomization service is loaded to the browser page; And the communication module is used for carrying out data communication based on the data communication mechanism if the atomization service calls the event processing center instance.
- 9. A terminal comprising a memory, a processor and a data communication program stored on the memory and operable on the processor, the data communication program when executed by the processor implementing the steps of the data communication method according to any one of claims 1 to 7.
- 10. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program executable for implementing the steps of the data communication method according to any one of claims 1 to 7.
Description
Data communication method, device, terminal and storage medium Technical Field The present invention relates to the field of data communications technologies, and in particular, to a data communications method, apparatus, terminal, and storage medium. Background In the Web application architecture, an Atomic Service (Atomic Service) has been widely used in the front-end development field as a design paradigm for breaking down a complex system into independent, reusable minimum functional units. Each of the atomization services typically exists in the form of an independent module or micro-front end that is loaded and executed by the browser environment. However, since the existing WEB atomization services are developed independently, the data and the variables of the existing WEB atomization services cannot be directly transmitted (e.g. shared and modified) in the same browser page, there are two modes of data transmission, the first mode is a mode of requesting through a network, and the second mode is a mode of local caching through a browser. The first approach has the disadvantage of consuming a lot of server resources and the second approach has the disadvantage of taking up the volume of the browser's local cache. Accordingly, the prior art has drawbacks and needs to be improved and developed. Disclosure of Invention The application provides a data communication method, a data communication device, a terminal and a storage medium, which are used for solving the technical problems that a large amount of server resources are consumed or the volume of a local cache of a browser is occupied when data transmission is carried out between atomization services in the related technology. In order to achieve the above purpose, the present application adopts the following technical scheme: A method of data communication, wherein the method comprises: initializing an event processing center instance in an operation framework carrying a plurality of atomization services, wherein a data communication mechanism is deployed in the event processing center instance; when the atomization service is loaded to the browser page, the event processing center instance is transmitted to the inside of the atomization service; and if the atomization service calls the event processing center instance, carrying out data communication with the target atomization service based on the data communication mechanism. According to the technical means, the event processing center instance is initialized in the operation frame carrying the plurality of atomization services, and the data transmission between the atomization services is performed based on the initialized event processing center instance, so that a large amount of server resources are not consumed or the local cache capacity of the browser is occupied, and the convenience and the efficiency of the data transmission between the atomization services are improved. In one implementation of the present application, the event processing center instance includes a service mapping table; when the atomization service is loaded to the browser page, the event processing center instance is transferred to the inside of the atomization service, and the method comprises the following steps: when an atomization service is loaded to a browser page, receiving a service identifier and a callback function which are transmitted by the atomization service; and if the service identifier does not exist in the service mapping table, adding the service identifier into the service mapping table, and storing the corresponding relation between the callback function and the service identifier. According to the technical means, the embodiment of the application provides the subscription binding method for the outside, and after each atomization service runs on the page, the event processing center instance is transferred to the inside of each atomization service in a property binding mode so as to be called by the event processing center instance. In one implementation of the present application, when an atomized service is loaded to a browser page, after receiving a service identifier and a callback function that are input by the atomized service, the method further includes: If the service identifier exists in the service mapping table, searching whether the callback function exists in a callback function set corresponding to the service identifier; And if not, storing the corresponding relation between the callback function and the service identifier. According to the technical means, the callback function is added in the service mapping table on the premise of ensuring that the callback function is not repeated, repeated storage of the callback function is avoided, resource waste caused by the fact that the same callback function is triggered for multiple times and the same logic is executed is avoided, and data errors caused by multiple times of execution when the callback function modifies shared dat