Event subscription and publishing method and device, electronic equipment and storage medium

By using hash calculation to generate primary keys, the modules are decoupled, which solves the problem of high module coupling, achieves seamless decoupling of event subscription and publishing, avoids compilation errors, and improves the convenience of development and maintenance.

CN121579547APending Publication Date: 2026-02-27HICI DIGITAL POWER TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511568846.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-30
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

In existing technologies, the high coupling between modules leads to the need to modify a large amount of logic when deleting or adding modules, affecting the convenience of development and maintenance as well as the portability of the program.

Method used

By hashing the event name to generate the corresponding primary key, and storing the callback function and user data in a hash table, decoupling between modules is achieved. When subscribing to and publishing events, the target function and data can be directly called through the hash table.

Benefits of technology

It achieves complete decoupling between modules, with no correlation between subscribed and published events, and the publication of unsubscribed events will not cause compilation errors, thus improving the convenience of development and maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121579547A_ABST
    Figure CN121579547A_ABST
Patent Text Reader

Abstract

The invention provides an event subscription and release method and device, electronic equipment and a storage medium, and the method comprises the steps: responding to triggering event subscription, and receiving a first event name, a callback function and user data of a to-be-subscribed event, and the user data represents an event type of the to-be-subscribed event; performing Hash calculation on the first event name to generate a corresponding first event name primary key; the callback function and the user data are stored in a hash table, and the first event name primary key is used for mapping the storage positions of the callback function and the user data in the hash table; responding to trigger event release, and receiving a second event name of the to-be-released event; performing Hash calculation on the second event name to generate a corresponding second event name primary key; and searching a corresponding target callback function and target user data in the hash table according to the second event name primary key. According to the method and the device, decoupling among different modules can be realized, so that engineering compilation errors cannot be caused after unsubscribed events are published.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of event subscription and publishing, and in particular to an event subscription and publishing method and device, electronic equipment and a storage medium. BACKGROUND

[0002] At present, although software development can realize corresponding functions, the coupling between modules in the software is relatively serious. If the API of a module is used in many other modules, it will lead to the need to modify the logic of all places where the module is used when deleting a module, which is very inconvenient for development and maintenance or program portability.

[0003] It is very inconvenient to modify and add new functions in a project code with high coupling, and therefore, a new event subscription and publishing method is needed to solve the above problems. SUMMARY

[0004] Therefore, the present application provides an event subscription and publishing method and device, electronic equipment and a storage medium, which can realize decoupling between different modules, so that the un-subscribed event will not cause engineering compilation errors after publishing.

[0005] The first aspect of the embodiment of the present application provides an event subscription and publishing method, comprising: in response to triggering event subscription, receiving a first event name, a callback function and user data of a to-be-subscribed event, wherein the user data represents the event type of the to-be-subscribed event; performing hash calculation on the first event name to generate a corresponding first event name primary key; storing the callback function and the user data in a hash table, wherein the first event name primary key is used to map the storage location of the callback function and the user data in the hash table; in response to triggering event publishing, receiving a second event name of a to-be-published event; performing hash calculation on the second event name to generate a corresponding second event name primary key; and finding a target callback function and target user data corresponding to the second event name primary key in the hash table.

[0006] In a possible implementation manner, the user data includes a user-defined data structure body; and the receiving manner of the user data includes receiving the data structure body input by the user, wherein the data structure body includes a data type and a data description, and the data structure body type can be used by an external program.

[0007] In a possible implementation manner, the receiving manner of the callback function includes receiving the callback function defined by the user in a source program file, wherein the parameter of the callback function is the data structure body.

[0008] In a possible implementation, the receiving, in response to the triggered event subscription, the first event name, the callback function and the user data of the event to be subscribed includes: receiving, in response to the triggered event subscription in the source program file, the first event name, the callback function and the user data.

[0009] In a possible implementation, the receiving, in response to the triggered event subscription in the source program file, the first event name, the callback function and the user data includes: calling an event subscription function in the source program file to receive the first event name, the callback function and the user data.

[0010] In a possible implementation, the receiving, in response to the triggered event publication, the second event name of the event to be published includes: calling an event publication function to receive the second event name.

[0011] In a possible implementation, the searching, according to the second event name primary key, the target callback function and the target user data corresponding to the second event name primary key in the hash table includes: determining a target storage location corresponding to the second event name primary key in the hash table; and determining the target callback function and the target user data stored in the target storage location.

[0012] In a second aspect, an event subscription and publication apparatus is also provided in the embodiments of the present application, and the apparatus includes a first receiving module, a first calculating module, a storage module, a second receiving module, a second calculating module and an event publication module. The first receiving module is configured to receive, in response to a triggered event subscription, a first event name, a callback function and user data of an event to be subscribed, where the user data represents an event type of the event to be subscribed. The first calculating module is configured to perform hash calculation on the first event name to generate a corresponding first event name primary key. The storage module is configured to store the callback function and the user data in a hash table, where the first event name primary key is used to map a storage location of the callback function and the user data in the hash table. The second receiving module is configured to receive, in response to a triggered event publication, a second event name of an event to be published. The second calculating module is configured to perform hash calculation on the second event name to generate a corresponding second event name primary key. The event publication module is configured to search, according to the second event name primary key, a target callback function and a target user data corresponding to the second event name primary key in the hash table.

[0013] In a third aspect, an electronic device is also provided in the embodiments of the present application, and the electronic device includes a processor and a memory. The memory is configured to store instructions, and the processor is configured to call the instructions in the memory, so that the electronic device performs the event subscription and publication method in the first aspect.

[0014] In a fourth aspect, an embodiment of the present application further provides a computer readable storage medium storing computer instructions, when the computer instructions are executed on an electronic device, the electronic device is caused to perform the event subscription and publishing method in the first aspect.

[0015] Compared with the related art, the embodiments of the present application have at least the following advantages: by performing hash calculation on the first event name, the corresponding first event name primary key is generated, so that the first event name primary key can be bound together with the callback function and the user data, that is, after the callback function and the user data are stored in the hash table, the first event name primary key can map the storage location of the callback function and the user data in the hash table. When the to-be-subscribed event triggers execution, the triggered event is published, that is, the event publishing function is called to obtain the second event name of the to-be-published event, and the second event name primary key is obtained by performing hash calculation on the second event name, so that the target callback function and the target user data can be directly called through the second event name primary key. It is worth noting that if the second event name does not subscribe any event callback function, the corresponding callback function pointer in the hash table is empty, and when the event publishing function is called, no operation will be performed, thereby realizing complete decoupling between modules, and there is no any association between the subscribed event and the published event. Whether or not to subscribe, the event can be normally published, but the event that is not subscribed will not perform any operation when the event is published, that is, even if the event that is not subscribed is published, it will not cause the engineering compilation error.

[0016] The technical effects obtained by the above-mentioned second aspect, third aspect and fourth aspect are similar to the technical effects obtained by the corresponding technical means in the first aspect, which will not be described here. BRIEF DESCRIPTION OF DRAWINGS

[0017] Figure 1 A step flowchart of an event subscription and publishing method provided by an embodiment of the present application; Figure 2 Another step flowchart of an event subscription and publishing method provided by an embodiment of the present application; Figure 3 A functional module diagram of an event subscription and publishing device provided by an embodiment of the present application; Figure 4 A structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0018] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the present application will be described in detail below in combination with the drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0019] The following description sets forth many specific details to provide a full understanding of this application. The described embodiments are only some, not all, of the embodiments of this application.

[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein in the specification of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application.

[0021] It should be further noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0022] In this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The terms "first," "second," "third," "fourth," etc. (if present) in the specification, claims, and drawings of this application are used to distinguish similar objects, not to describe a specific order or sequence.

[0023] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0024] For ease of understanding, some concepts related to the embodiments of this application are illustrated and explained by way of example for reference.

[0025] Event subscription functions are a mechanism for registering event callback functions, allowing developers to execute specific code when an event occurs. Their core functionality includes subscribing to, triggering, and unsubscribing from events, and they are commonly found in front-end development, cross-platform communication, and other fields.

[0026] Event publishing function: a program interface used to trigger events and notify relevant listeners or processing functions, commonly used in event-driven programming models.

[0027] Callback function: a programming concept that involves passing a function as an argument to another function, which is then called under certain conditions. It is commonly used in asynchronous operations, event handling, and higher-order functions, allowing code to execute custom logic at specific times.

[0028] Hash calculation: a process that converts input data of arbitrary length into a fixed-length output through an algorithm, widely used in data integrity verification, password storage, and other fields.

[0029] Please refer to Figure 1 , Figure 1 is a step flowchart of an embodiment of the event subscription and publishing method of the present application. The order of the steps in the flowchart can be changed according to different needs, and some steps can be omitted.

[0030] It should be noted that the event subscription and publishing method of the embodiments of the present application can be applied to the event subscription and publishing scenario, and the execution subject can be an event subscription and publishing device, for example, in the case of needing to monitor hardware failures in real time, the event subscription and publishing device can be used to subscribe and publish fault events. Of course, the event subscription and publishing method can also be applied to other scenarios that need to subscribe and publish events, and the present application does not make specific limitations on this.

[0031] The specific process of the embodiment is shown in Figure 1 , including the following steps: S101, in response to triggering event subscription, receiving a first event name, a callback function, and user data of a to-be-subscribed event, wherein the user data represents the event type of the to-be-subscribed event.

[0032] In some embodiments, the user data includes a user-defined data structure; the receiving method of the user data includes receiving a user-input data structure, wherein the data structure includes data type and data description, and the data structure type can be used by external programs.

[0033] In some embodiments, the receiving method of the callback function includes receiving a callback function defined by the user in the source program file, wherein the parameter of the callback function is a data structure.

[0034] In some embodiments, in response to triggering event subscription in the source program file, the first event name, the callback function, and the user data are received.

[0035] In some embodiments, the event subscription function is called in the source program file to receive the first event name, the callback function, and the user data.

[0036] S102, hash computing the first event name to generate a corresponding first event name primary key.

[0037] S103, storing the callback function and the user data in a hash table, wherein the first event name primary key is used to map the storage location of the callback function and the user data in the hash table.

[0038] Regarding S102 and S103, specifically, the hash value obtained by hash computing the first event name as the key value is the first event name primary key, and the first event name primary key is the subscript of the array. The position of the callback function and the user data can be quickly located and the subscribed event callback function can be called through the array subscript.

[0039] S104, in response to triggering event publishing, receiving a second event name of an event to be published.

[0040] In some embodiments, the event publishing function is called to receive the second event name.

[0041] S105, hash computing the second event name to generate a corresponding second event name primary key.

[0042] Specifically, when the event needs to be triggered to execute, the event publishing function only needs to be called at an appropriate place, and the input parameter of the event publishing function is only a string of event name. The string is an arbitrary custom string, which is converted into a subscript of a structure array after the event is subscribed, and then the user callback function is bound together.

[0043] S106, finding the corresponding target callback function and target user data in the hash table according to the second event name primary key.

[0044] Regarding how to find the corresponding target callback function and target user data in the hash table according to the second event name primary key, it will be described in detail in subsequent embodiments. In order to avoid repetition, it will not be described here.

[0045] Compared with the related art, the embodiments of the present application have at least the following advantages: by performing hash calculation on the first event name, the corresponding first event name primary key is generated, so that the first event name primary key can be bound together with the callback function and the user data, that is, after the callback function and the user data are stored in the hash table, the first event name primary key can map the storage location of the callback function and the user data in the hash table. When the to-be-subscribed event triggers execution, the triggered event is published, that is, the event publishing function is called to obtain the second event name of the to-be-published event, and the second event name primary key is obtained by performing hash calculation on the second event name, so that the target callback function and the target user data can be directly called through the second event name primary key. It is worth noting that if the second event name does not subscribe any event callback function, the corresponding callback function pointer in the hash table is empty, and no operation will be performed after the event publishing function is called when it is empty, so that the modules are completely decoupled, there is no any association between the subscribed event and the published event, and the event can be normally published whether it is subscribed or not, except that the event publishing will not perform any operation when it is not subscribed, that is, the event that is not subscribed will not cause the engineering compilation error after being published.

[0046] Please refer to Figure 2 , Figure 2 is a step flowchart of an embodiment of the event subscription and publishing method of the present application. The order of the steps in the flowchart can be changed according to different needs, and some steps can be omitted. The event subscription and publishing method can be applied to the event subscription and publishing device described above, but is not limited thereto, and the embodiments of the present application do not limit the same.

[0047] The present embodiment is a specific description of the foregoing embodiments, mainly explaining how to find the corresponding target callback function and target user data according to the second event name primary key in the hash table. In this way, the accuracy of event publishing can be improved.

[0048] The specific process of the present embodiment is shown in Figure 2 , including the following steps: S201, in response to a triggered event subscription, receiving a first event name of a to-be-subscribed event, a callback function and user data, wherein the user data represents an event type of the to-be-subscribed event.

[0049] S202, performing hash calculation on the first event name to generate a corresponding first event name primary key.

[0050] S203, storing the callback function and the user data in a hash table, wherein the first event name primary key is used to map the storage location of the callback function and the user data in the hash table.

[0051] S204, in response to the trigger event publishing, receiving a second event name of the event to be published.

[0052] S205, performing hash calculation on the second event name to generate a corresponding second event name primary key.

[0053] S201 to S205 of the embodiment are similar to S101 to S105 of the foregoing embodiment, and thus will not be described herein again to avoid repetition.

[0054] S206, determining a target storage location in the hash table corresponding to the second event name primary key.

[0055] In some embodiments, the second event name primary key is a hash value calculated according to the second event name. Since, in the event subscription process, the first event name primary key is generated according to the first event name of the event to be subscribed, the storage location of the callback function and the user data in the hash table is mapped, the target storage location corresponding to the second event name primary key can be found in the hash table.

[0056] S207, determining a target callback function and target user data stored in the target storage location.

[0057] It is worth noting that, by using the event subscription and publishing method of the embodiment, the compilation of the entire project will not be affected after adding or deleting a module. For example, after deleting the corresponding event subscription, when the event is published, no operation will be performed because the event is not subscribed, and no code compilation error and code logic error will occur.

[0058] Compared with the related art, the embodiments of the present application have at least the following advantages: by performing hash calculation on the first event name, a corresponding first event name primary key is generated, so that the first event name primary key can be bound together with the callback function and the user data, that is, after the callback function and the user data are stored in the hash table, the first event name primary key can map the storage location of the callback function and the user data in the hash table. When the to-be-subscribed event triggers execution, the triggered event is published, that is, the event publishing function is called to obtain the second event name of the to-be-published event, and the second event name primary key is obtained by performing hash calculation on the second event name, so that the target callback function and the target user data can be directly called through the second event name primary key. It is worth noting that if the second event name does not subscribe any event callback function, the corresponding callback function pointer in the hash table is empty, and no operation will be performed after the event publishing function is called when it is empty, so that the modules are completely decoupled, and there is no any association between the subscribed event and the published event. Whether or not to subscribe, the event can be normally published, except that the event without subscription will not perform any operation when publishing, that is, the event that is not subscribed will not cause the engineering compilation error after being published.

[0059] Based on the same idea as the event subscription and publishing method in the above embodiments, the present application also provides an event subscription and publishing device, which can be used to execute the above event subscription and publishing method. For the convenience of description, only the parts related to the embodiments of the present application are shown in the structural schematic diagram of the event subscription and publishing device, and those skilled in the art can understand that the illustrated structure does not constitute a limitation on the device, which can include more or fewer components than the illustrated, or combine certain components, or different component arrangements.

[0060] As shown in Figure 3 The event subscription and publishing device 30 includes a first receiving module 301, a first calculation module 302, a storage module 303, a second receiving module 304, a second calculation module 305, and an event publishing module 306. In some embodiments, the above modules can be programmable software instructions stored in a memory and executable by a processor. It can be understood that in other embodiments, the above modules can also be program instructions or firmware fixed in the processor.

[0061] The first receiving module 301 is configured to receive a first event name, a callback function and user data of a to-be-subscribed event in response to a triggered event subscription, wherein the user data represents an event type of the to-be-subscribed event; The first calculation module 302 is configured to perform hash calculation on the first event name to generate a corresponding first event name primary key; The storage module 303 is configured to store the callback function and the user data in a hash table, wherein the first event name primary key is used to map the storage position of the callback function and the user data in the hash table. The second receiving module 304 is configured to receive a second event name of a to-be-published event in response to a trigger event publishing. The second computing module 305 is configured to perform hash calculation on the second event name to generate a corresponding second event name primary key. The event publishing module 306 is configured to find a target callback function and target user data corresponding to the second event name primary key in the hash table.

[0062] The event subscription and publishing apparatus 30 provided by the above embodiment can implement the technical solutions described in the above event subscription and publishing method embodiments, and the principles of the implementation of the above modules or units can be referred to the corresponding content in the above event subscription and publishing method embodiments, which will not be described here.

[0063] Please refer to Figure 4 , Figure 4 FIG. 4 is a schematic diagram of an electronic device according to an embodiment of the present application. In the embodiment of the present application, the electronic device 400 includes a processor 401, a memory 402, and a display 403. Figure 4 Only some components of the electronic device 400 are shown, but it should be understood that it is not required to implement all the shown components, and more or fewer components can be alternatively implemented.

[0064] The processor 401 may, in some embodiments, be a central processing unit (CPU), a microprocessor, or other data processing chip, configured to run program codes or process data stored in the memory 402, such as the event subscription and publishing method in the present application.

[0065] In some embodiments, the processor 401 can be a single server or a server group. The server group can be centralized or distributed. In some embodiments, the processor 401 can be local or remote. In some embodiments, the processor 401 can be implemented in a cloud platform. In an embodiment, the cloud platform can include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an inter-internal cloud, a multi-cloud, etc., or any combination thereof.

[0066] The memory 402 can be an internal storage unit of the electronic device 400, such as a hard disk or a memory of the electronic device 400 in some embodiments. The memory 402 can also be an external storage device of the electronic device 400, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the electronic device 400 in other embodiments.

[0067] Further, the memory 402 can include both an internal storage unit and an external storage device of the electronic device 400. The memory 402 is used to store application software and various data installed on the electronic device 400.

[0068] The display 403 can be an LED display, a liquid crystal display, a touch liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, etc. in some embodiments. The display 403 is used to display information of the electronic device 400 and to display visualized user application programs. The components 401-403 of the electronic device 400 communicate with each other through a system bus.

[0069] In an embodiment, when the processor 401 executes the event subscription and publishing program in the memory 402, the following steps can be implemented: In response to triggering an event subscription, a first event name of an event to be subscribed, a callback function, and user data are received, wherein the user data represents an event type of the event to be subscribed; The first event name is hashed to generate a corresponding first event name primary key; The callback function and the user data are stored in a hash table, wherein the first event name primary key is used to map the storage location of the callback function and the user data in the hash table; In response to triggering an event publishing, a second event name of an event to be published is received; The second event name is hashed to generate a corresponding second event name primary key; According to the second event name primary key, a target callback function and target user data are found in the hash table.

[0070] It should be understood that, in addition to the above functions, the processor 401 can also implement other functions when executing the event subscription and publishing program in the memory 402. For details, please refer to the description of the corresponding method embodiments.

[0071] Further, the type of the electronic device 400 is not limited in the embodiments of the present application. The electronic device 400 can be a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device, a laptop computer, or the like. Exemplary embodiments of the portable electronic device include, but are not limited to, a portable electronic device running an IOS, an android, a microsoft, or other operating system. The portable electronic device can also be other portable electronic devices, such as a laptop computer having a touch-sensitive surface (e.g., a touch panel), and the like. It should also be understood that in some other embodiments of the present application, the electronic device 400 can not be a portable electronic device, but a desktop computer having a touch-sensitive surface (e.g., a touch panel).

[0072] Accordingly, the embodiments of the present application also provide a computer readable storage medium for storing computer readable programs or instructions, which, when executed by a processor, can implement the steps or functions in the event subscription and publication method provided by the above-mentioned method embodiments.

[0073] Those skilled in the art can understand that all or part of the processes of the above-mentioned embodiments can be completed by a computer program instructing relevant hardware (such as a processor, a controller, etc.) to complete. The computer program can be stored in a computer readable storage medium. The computer readable storage medium includes a magnetic disk, an optical disk, a read-only memory, a random access memory, and the like.

[0074] The event subscription and publication method, device, electronic device, and storage medium provided by the present application are described in detail above. The principles and implementation manners of the present application are described by applying specific examples. The above description of the embodiments is only used to help understand the method of the present application and its core idea. Meanwhile, for those skilled in the art, according to the idea of the present application, the specific implementation manner and application range can be changed. In summary, the content of the specification should not be understood as a limitation of the present application.

Claims

1. An event subscription and publishing method, characterized in that, include: The system responds to the event subscription by receiving the first event name, callback function, and user data of the event to be subscribed to, wherein the user data represents the event type of the event to be subscribed to. Perform a hash calculation on the first event name to generate the corresponding primary key of the first event name; The callback function and the user data are stored in a hash table, wherein the first event name primary key is used to map the storage location of the callback function and the user data in the hash table; The response triggers the publication of an event, and receives the second event name of the event to be published. Perform a hash calculation on the second event name to generate the corresponding second event name primary key; The target callback function and target user data are retrieved from the hash table based on the second event name primary key.

2. The event subscription and publishing method according to claim 1, characterized in that, The user data includes user-defined data structures; The methods for receiving user data include: The system receives a data structure input from a user, wherein the data structure includes a data type and a data description, and the data structure type can be used by an external program.

3. The event subscription and publishing method according to claim 2, characterized in that, The callback function can be received in the following ways: Receive the callback function defined by the user in the source program file, wherein the parameter of the callback function is the data structure.

4. The event subscription and publishing method according to claim 3, characterized in that, The response trigger event subscription receives the first event name, callback function, and user data of the event to be subscribed to, including: The source code file responds to the event subscription and receives the first event name, the callback function, and the user data.

5. The event subscription and publishing method according to claim 4, characterized in that, The step of responding to the event subscription in the source program file and receiving the first event name, the callback function, and the user data includes: The event subscription function is called in the source program file to receive the first event name, the callback function, and the user data.

6. The event subscription and publishing method according to claim 1, characterized in that, The response triggers the publication of an event, and receives the second event name of the event to be published, including: Call the event publishing function and receive the second event name.

7. The event subscription and publishing method according to any one of claims 1 to 6, characterized in that, The step of searching for the corresponding target callback function and target user data in the hash table based on the second event name primary key includes: Determine the target storage location in the hash table corresponding to the primary key of the second event name; Determine the target callback function and the target user data stored in the target storage location.

8. An event subscription and publishing device, characterized in that, include: The system comprises a first receiving module, a first computing module, a storage module, a second receiving module, a second computing module, and an event publishing module; The first receiving module is used to respond to the trigger event subscription, and receive the first event name, callback function and user data of the event to be subscribed, wherein the user data represents the event type of the event to be subscribed; The first calculation module is used to perform a hash calculation on the first event name to generate a corresponding first event name primary key; The storage module is used to store the callback function and the user data in a hash table, wherein the first event name primary key is used to map the storage location of the callback function and the user data in the hash table; The second receiving module is used to respond to the trigger event publication and receive the second event name of the event to be published; The second calculation module is used to perform hash calculation on the second event name to generate the corresponding second event name primary key; The event publishing module is used to look up the corresponding target callback function and target user data in the hash table based on the second event name primary key.

9. An electronic device, the electronic device comprising a processor and a memory, characterized in that, The memory is used to store instructions, and the processor is used to invoke the instructions in the memory to cause the electronic device to execute the event subscription and publishing method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed on an electronic device, cause the electronic device to perform the event subscription and publishing method as described in any one of claims 1 to 7.