Data binding method, device, electronic device and readable storage medium
By using the data binding business center layer in terminal applications to bind the Rust data layer to the UI layer, the problem of difficulty in binding the underlying data to the upper UI state is solved, and the true consistency of the underlying data across platforms and data is achieved.
Patent Information
- Application Number
- CN202311862683.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2043-12-29
AI Technical Summary
It is difficult to bind the underlying data of existing terminal applications to the upper UI state, and it is impossible to achieve true cross-platform underlying data.
Through the data binding service center layer, the Rust data layer in the Rust dynamic link library is bound to the target page UI layer. When monitoring the data changes in the Rust data layer, the corresponding data change operations are performed on the target page UI layer through the data binding service center layer.
It realizes the effective binding of the underlying data of terminal applications and the upper UI status, solves the cross-platform problem of underlying data, and ensures data consistency and real-time updates.
Smart Images

Figure CN117827315B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and in particular relates to a data binding method, device, electronic device and readable storage medium. Background Art
[0002] At present, terminal applications (Android / iOS / Mac / PC) use the underlying cross-platform more and more frequently, but it is difficult to bind the underlying data with the upper UI state; it is difficult to truly share the underlying data with all upper platforms. The common practice at present is that the underlying layer needs a set of data and the upper layer also needs a set of data cache. When the data changes, both the underlying and upper layer data are updated; and the upper layer data uses the SDK itself or a third-party open source data binding method; this makes the program design difficult, and it is impossible to achieve true underlying data cross-platform, and two sets of data still need to be maintained. There may be problems in a certain link during program operation, resulting in bugs in which the two sets of data are inconsistent; at the same time, it also increases the difficulty for developers and customer service personnel in locating existing network problems. They need to check whether the underlying data is normal before checking whether the upper layer data is normal.
[0003] Therefore, a data binding method is urgently needed to solve the problem that it is difficult to bind the underlying data of existing terminal applications with the upper-level UI state, and it is impossible to achieve true cross-platform underlying data. Summary of the invention
[0004] The embodiment of the present invention provides a data binding method, which aims to solve the problem that it is difficult to bind the underlying data of existing terminal applications with the upper UI state, and it is impossible to achieve true cross-platform underlying data. The Rust data layer in the Rust dynamic link library is data-bound with the target page UI layer through the data binding business center layer. When the data change in the Rust data layer is monitored, the corresponding data change operation is performed on the target page UI layer through the data binding business center layer, so as to obtain the changed display page, which solves the problem that it is difficult to bind the underlying data of the terminal application with the upper UI state, and it is impossible to achieve true cross-platform underlying data.
[0005] The embodiment of the present invention is implemented by providing a data binding method, comprising the following steps:
[0006] Loading a Rust dynamic link library, wherein the Rust dynamic link library includes a Rust data layer;
[0007] Load the data binding business center layer;
[0008] Data binding is performed between the Rust data layer in the Rust dynamic link library and the target page UI layer through the data binding business center layer;
[0009] When data changes in the Rust data layer are monitored, corresponding data change operations are performed on the target page UI layer through the data binding business center layer to obtain a changed display page.
[0010] Optionally, the loading data binding business center layer includes:
[0011] Get the data structure of the data binding business center layer;
[0012] According to the data structure of the data binding service center layer, a data binding service center layer is obtained.
[0013] Optionally, the step of obtaining the data structure of the data binding business center layer includes:
[0014] Get the data identifier of the data binding business center layer;
[0015] Acquire multiple page identifiers corresponding to the data representation;
[0016] The data structure of the data binding service center layer is obtained according to the data identifier of the data binding service center layer and a plurality of page identifiers corresponding to the data identifier.
[0017] Optionally, the step of obtaining the data identifier of the data binding service center layer includes:
[0018] Get the page ID;
[0019] Get component ID;
[0020] Get component hash value;
[0021] A data identifier of a data binding business center layer is obtained according to the page identifier, the component identifier and the component hash value.
[0022] Optionally, before the step of data binding the Rust data layer in the Rust database with the UI layer through the data binding business center layer, the method further includes:
[0023] Support data binding settings for UI components through preset setting rules.
[0024] Optionally, when the data change in the Rust data layer is monitored, a corresponding data change operation is performed on the UI layer through the data binding business center layer to obtain an updated display page, including:
[0025] When new data is detected in the Rust data layer, the corresponding data addition operation is performed on the UI layer through the data binding business center layer to obtain the first display page after the data is added;
[0026] When data deletion is detected in the Rust data layer, the corresponding data deletion operation is performed on the UI layer through the data binding business center layer to obtain the second display page after data deletion.
[0027] When data update in the Rust data layer is monitored, a corresponding data update operation is performed on the UI layer through the data binding business center layer to obtain a third display page after the data is updated.
[0028] Optionally, after the step of performing a corresponding data change operation on the UI layer through the data binding business center layer when data changes in the Rust data layer are monitored, the method further includes:
[0029] When the page destruction is detected, the page identifier is passed to move the corresponding page in the data binding business center layer, and the Rust data layer removes the corresponding data identifier.
[0030] The embodiment of the present invention further provides a data binding device, comprising:
[0031] A first loading module, used to load a Rust dynamic link library, wherein the Rust dynamic link library includes a Rust data layer;
[0032] The second loading module is used to load the data binding business center layer;
[0033] A data binding module, used to perform data binding between the Rust data layer in the Rust dynamic link library and the target page UI layer through the data binding business center layer;
[0034] The first processing module is used to monitor the data change in the Rust data layer, and perform corresponding data change operations on the target page UI layer through the data binding business center layer to obtain the changed display page.
[0035] An embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein when the processor executes the computer program, a data binding method as described in any embodiment is implemented.
[0036] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, a data binding method as described in any one of the embodiments is implemented.
[0037] The beneficial effects achieved by the present invention are as follows: the present application loads a Rust dynamic link library, the Rust dynamic link library includes a Rust data layer; loads a data binding business center layer; performs data binding between the Rust data layer in the Rust dynamic link library and the target page UI layer through the data binding business center layer; when data changes in the Rust data layer are monitored, the corresponding data change operation is performed on the target page UI layer through the data binding business center layer to obtain a changed display page. The Rust data layer in the Rust dynamic link library is data bound to the target page UI layer through the data binding business center layer; when data changes in the Rust data layer are monitored, the corresponding data change operation is performed on the target page UI layer through the data binding business center layer to obtain a changed display page, thereby solving the problem that it is difficult to bind the underlying data of the terminal application to the upper UI state, and it is impossible to achieve true cross-platform underlying data. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A flowchart of a data binding method provided in an embodiment of the present application;
[0039] Figure 2 A structural diagram of another data binding method provided in an embodiment of the present application;
[0040] Figure 3 A schematic diagram showing another data binding method provided in an embodiment of the present application is shown;
[0041] Figure 4 A schematic diagram of another data binding method provided in an embodiment of the present application;
[0042] Figure 5 A schematic diagram showing a View component of a UI layer provided in an embodiment of the present application;
[0043] Figure 6 A schematic diagram of another data binding method provided in an embodiment of the present application;
[0044] Figure 7 A schematic diagram of the structure of a data binding device provided in an embodiment of the present application;
[0045] Figure 8 A schematic diagram of the structure of a second loading module provided in an embodiment of the present application;
[0046] Fig. 9 A schematic diagram of the structure of the acquisition submodule provided in an embodiment of the present application;
[0047] Fig.10 A schematic diagram of the structure of a first acquisition unit provided in an embodiment of the present application;
[0048] Fig.11A structural diagram of another data binding device provided in an embodiment of the present application;
[0049] Fig.12 A schematic diagram of the structure of a first processing module provided in an embodiment of the present application;
[0050] Fig.13 A structural diagram of another data binding device provided in an embodiment of the present application;
[0051] Fig.14 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0053] Embodiment 1
[0054] In this embodiment, Figure 1 A flow chart of a data binding method provided by an embodiment of the present application is shown. Figure 1 As shown, the method includes steps S101 to S104. The specific implementation principle of each step is as follows:
[0055] S101. Load the Rust dynamic link library.
[0056] In an embodiment of the present invention, the above-mentioned data binding method is used to bind the underlying data of the terminal application to the UI, and the APP data cache is stored in the Rust dynamic link library, so that the underlying data can be bound to the upper-level UI state across the underlying platform, and the underlying data changes and the upper-level UI state changes in real time.
[0057] The above Rust dynamic link library can be the underlying Rust dynamic link library, which is mainly responsible for business processing, data processing, and data caching. The Rust dynamic link library can also be a so library or a dll dynamic link library.
[0058] The Rust dynamic link library includes the Rust data layer, which has a layer for monitoring business data changes, including network data changes and local data changes; the data structure of the Rust data layer is Map<Data T, List <tag>>, the data generic T corresponds to multiple Tags, and it can be considered that each Tag corresponds to a specific View.
[0059] It should be noted that when the terminal application (APP) is initialized, the Rust dynamic link library is loaded first.
[0060] S102, loading data binding business center layer.
[0061] In the embodiment of the present invention, the data binding service center layer can be understood as a central management layer for implementing data binding and state management between the bottom layer data and the upper layer UI.
[0062] Furthermore, the data structure of the data binding business center layer is ViewMap<Tag,View> , Tag is a data identifier. Tag is mainly used as an identifier to notify the upper layer which View has changed when the underlying Rust data changes. View corresponds to the View displayed in the UI layer.
[0063] Furthermore, the data binding business center layer is responsible for updating the specific view components in the UI layer after actively acquiring data and updating the specific View components in the UI layer after Rust feedbacks data changes.
[0064] It should be noted that the data binding business center layer listens to the data change notification of the Rust data layer, obtains the corresponding View through the data structure Tag of the data binding business center layer, and performs corresponding operations.
[0065] S103, data binding is performed between the Rust data layer in the Rust dynamic link library and the target page UI layer through the data binding business center layer.
[0066] In the embodiment of the present invention, the above-mentioned target page UI layer refers to the interface layer that directly interacts with the user in the APP.
[0067] In the embodiment of the present invention, when the UI is initialized, if databind=true is preset, it means that the UI component needs to support data binding.
[0068] Furthermore, by setting databind=true to support data binding operations on UI components, data binding of UI components can be completed quickly and easily to achieve automatic updating and response of data.
[0069] The above data binding can be understood as a data binding process that enables the content displayed on the page to be automatically updated as the background data changes.
[0070] In one embodiment, the Rust data layer is data-bound to the target page UI layer through the data-binding business center layer. When the UI component obtains data for the first time, it passes the Tag to the Rust data layer, and the Rust data layer matches the data value to the Tag. When the data in the Rust data layer changes, the UI does not need to be manually refreshed or call the code refresh method. The specific View is obtained through the data-binding business center layer, and the View calls the setValue(value) method to refresh the UI layer. The setValue(value) method can be used to change the value of an element, that is, the value of a form element.
[0071] In the embodiment of the present invention, all Views displayed in the UI layer need to inherit BaseView. BaseView provides a setValue method. The value in setValue supports generics, that is, data model model or basic data type. If value == null, the View component is hidden. BaseView supports listview components. The listview components in baseview will provide setValue(list[]), addValue(T generic), updateValue(id, T generic), and removeValue(id) methods.
[0072] In an embodiment of the present invention, the Rust data layer is data-bound to the target page UI layer through the data binding business center layer, so that the underlying Rust data changes and the UI changes in real time.
[0073] S104. When data changes in the Rust data layer are monitored, corresponding data change operations are performed on the target page UI layer through the data binding business center layer to obtain the changed display page.
[0074] In the embodiment of the present invention, the Rust data layer has a layer for monitoring business data changes, including network data changes and local data changes. As long as the data is added, deleted, or modified, the Rust layer for monitoring business data changes will send a notification to the upper data binding business center layer. Specifically, the specific data structure of the notification includes: Tag, data value (generic), data status, data ID; data status includes 1 for adding data, 2 for updating data, and 3 for deleting data. The data ID is mainly used for listview data update operations.
[0075] Furthermore, the data changes in the Rust data layer are monitored through the data binding business center layer, and the corresponding View is obtained through the data binding business center layer data structure Tag. After successful acquisition, corresponding data change operations are performed according to the specific data change status.
[0076] The above data change states include: state==1 indicates that data is newly added, state==2 indicates that data is updated, and state==3 indicates that data is deleted.
[0077] In an embodiment of the present invention, the changed data of the Rust data layer mainly comes from network layer data changes and local data changes; network layer data changes mainly include synchronization of local data with server data, and the server actively sends data change notifications to the Rust websocket; it can also be data changes caused by local business logic.
[0078] Furthermore, when a logic of the Rust data layer triggers a data value change, the Rust data layer will notify the upper data binding business center layer, pass the data structure Tag, and generically give it to the data binding business center layer. The data binding business center layer monitors the data change and obtains the specific View through the data structure ViewMap.get(tag). The View calls the setValue(value) method to refresh the view layer; if a data corresponds to multiple tags, it will loop through the list. <tag>After each traversal, the Tag is obtained and ViewMap.get(Tag) is called to obtain the specific View. The View calls the setValue(value) method to refresh the UI layer.
[0079] In one embodiment, when new data is detected in the Rust data layer, the corresponding View is obtained by binding the business center layer data structure Tag. After successful acquisition, corresponding data is added to the UI layer data according to the status of the new data to obtain an updated display page.
[0080] In another embodiment, when data deletion is detected in the Rust data layer, the corresponding View is obtained by binding the business center layer data structure Tag to the data. After successful acquisition, the UI layer data is deleted accordingly according to the status of the data deletion to obtain an updated display page.
[0081] In another embodiment, when data update in the Rust data layer is monitored, the corresponding view is obtained by binding the business center layer data structure Tag, and after successful acquisition, the UI layer data is updated accordingly according to the data update status to obtain an updated display page.
[0082] It should be noted that when data is added, if the View is a listview (list component), the listview.add(value) method is called, and if the View is a normal component, the view.setValue(value) method is called; when data is updated, if the View is a listview (list component), the listview.update(id,value) method is called, and for normal components, the view.setValue(value) method is called; when data is deleted, if the View is a listview (list component), the listview.remove(id) method is called, and for normal components, the view.remove() method is called.
[0083] In this embodiment, the Rust dynamic link library is loaded, and the Rust dynamic link library includes the Rust data layer; the data binding business center layer is loaded; the Rust data layer in the Rust dynamic link library is data-bound with the target page UI layer through the data binding business center layer; when the data change in the Rust data layer is monitored, the corresponding data change operation is performed on the target page UI layer through the data binding business center layer to obtain the changed display page. The Rust data layer in the Rust dynamic link library is data-bound with the target page UI layer through the data binding business center layer, and when the data change in the Rust data layer is monitored, the corresponding data change operation is performed on the target page UI layer through the data binding business center layer to obtain the changed display page, which solves the problem that it is difficult to bind the underlying data of the terminal application with the upper UI state, and it is impossible to achieve true cross-platform underlying data.
[0084] Optionally, the steps of binding the data to the business center layer include:
[0085] Get the data structure of the data binding business center layer.
[0086] According to the data structure of the data binding business center layer, the data binding business center layer is obtained.
[0087] In the embodiment of the present invention, the data structure of the data binding business center layer can be ViewMap<Tag,View> Among them, the data identifier Tag is mainly an identifier used to notify the upper layer which View has discovered the change when the underlying Rust data changes.
[0088] The above data binding business center layer is used to listen to the Rust data layer data change notification, obtain the corresponding page View through the data structure Tag of the data binding business center layer, and perform corresponding operations. The data binding business center layer is mainly responsible for updating the specific View components in the UI layer after actively acquiring data and updating the specific view components in the UI layer after Rust feedback data changes.
[0089] Optionally, the step of obtaining the data structure of the data binding business center layer includes:
[0090] Get the data identifier of the data binding business center layer.
[0091] Get multiple page identifiers corresponding to the data identifier.
[0092] According to the data identifier and the multiple page identifiers corresponding to the data identifier, the data structure of the data binding business center layer is obtained.
[0093] In the embodiment of the present invention, the data identifier may be a Tag, and the page identifier may be a View.
[0094] Furthermore, the data tag is used to identify changes in the underlying Rust data layer data and notify the upper layer which View has changed.
[0095] The data structure of the above data binding business center layer can be ViewMap<Tag,View> .
[0096] Optionally, the step of obtaining the data identifier of the data binding business center layer includes:
[0097] Get the page ID.
[0098] Get the component ID.
[0099] Get the component hash value.
[0100] According to the page identifier, component identifier and component hash value, the data identifier of the data binding business center layer is obtained.
[0101] In the embodiment of the present invention, the page identifier may be a page ID, and the component identifier may be a component ID.
[0102] The above component hash value can be understood as a method for quickly finding data in a data structure by mapping key values to positions in a hash table. A hash function can map different input values to different output values, thereby achieving efficient data search.
[0103] The above data identifier can be a Tag. Tag is mainly an identifier used to notify the upper layer which View has discovered the change when the data in the underlying Rust data layer changes.
[0104] It should be noted that the generation logic of the data identification Tag can be page ID+component ID+component hash value.
[0105] Optionally, also include:
[0106] Support data binding settings for UI components through preset setting rules.
[0107] In the embodiment of the present invention, the above-mentioned preset setting rule may be databind=true, and databind=true indicates that the UI component needs to support data binding settings.
[0108] Furthermore, when the UI component obtains data for the first time, it passes the Tag to the Rust data layer, and the Rust data layer matches the data value to the Tag. When the Rust data layer data changes after the UI layer obtains the Rust data layer data for the first time and assigns the value to the UI, the UI does not need to be manually refreshed or call the code refresh method.
[0109] It should be noted that when the UI is initialized, if databind=true is set, it means that the UI component needs to support data binding. By supporting data binding operations on UI components according to preset setting rules, data binding of UI components can be completed conveniently and quickly to achieve automatic update and response of data.
[0110] Optionally, when data changes in the Rust data layer are monitored, the steps of performing corresponding data change operations on the UI layer through the data binding business center layer to obtain an updated display page include:
[0111] When new data is detected in the Rust data layer, the corresponding data addition operation is performed on the UI layer through the data binding business center layer to obtain the first display page after the data is added.
[0112] When data deletion is detected in the Rust data layer, the corresponding data deletion operation is performed on the UI layer through the data binding business center layer to obtain the second display page after the data is deleted.
[0113] When data updates are detected in the Rust data layer, corresponding data update operations are performed on the UI layer through the data binding business center layer to obtain the third display page after the data is updated.
[0114] In the embodiment of the present invention, all Views displayed in the UI layer need to inherit BaseView. BaseView provides a setValue method. The value in setValue supports generics, that is, data model model or basic data type. If value == null, the View component is hidden. BaseView supports listview components. The listview components in baseview will provide setValue(list[]), addValue(T generic), updateValue(id, T generic), and removeValue(id) methods.
[0115] When the data binding business center layer monitors the new data in the Rust data layer, the corresponding View is obtained through the data binding business center layer's data structure Tag. If the View is a list component (listview), the listview.add(value) method is used to add data to the corresponding data in the UI layer; if the View is a normal component, the view.setValue(value) method is used to add data to the corresponding data in the UI layer to obtain the first display page after the data is added.
[0116] When data deletion in the Rust data layer is monitored through the data binding business center layer, the corresponding View is obtained through the data structure Tag of the data binding business center layer. If the View is a list component (listview), the listview.add(value) method is used to delete the corresponding data in the UI layer; if the View is a normal component, the view.setValue(value) method is used to delete the corresponding data in the UI layer to obtain the second display page after data deletion.
[0117] When the data update in the Rust data layer is monitored through the data binding business center layer, the corresponding View is obtained through the data structure Tag of the data binding business center layer. If the View is a list component (listview), the listview.add(value) method is used to update the data corresponding to the UI layer; if the View is a normal component, the view.setValue(value) method is used to update the data corresponding to the UI layer to obtain the third display page after the data is updated.
[0118] It should be noted that the data binding business center layer monitors the data and finds changes, obtains the specific View through ViewMap.get(Tag), and the View calls the setValue(value) method to refresh the UI layer. The UI layer page does not need to be refreshed manually or call the code refresh method.
[0119] In the embodiment of the present invention, when the data in the Rust data layer changes, the Rust data layer will notify the upper data binding business center layer, pass the Tag and generics (data model, basic data type) to the data binding business center layer. When the data binding business center layer monitors the data change, it obtains the specific View through the data structure ViewMap.get(Tag) of the data binding business center layer. The View calls the setValue(value) method to refresh the view layer. If one data corresponds to multiple Tags, the list will be traversed in a loop. <tag>After each traversal, the Tag is obtained and ViewMap.get(tag) is called to obtain the specific View. The View calls the setValue(value) method to refresh the UI layer.
[0120] Optionally, also include:
[0121] When the page destruction is detected, the page identifier is passed to the corresponding page in the mobile data binding business center layer, and the Rust data layer removes the corresponding data identifier.
[0122] In the embodiment of the present invention, the above page destruction can be understood as page closing.
[0123] In the embodiment of the present invention, when the monitoring page is closed or destroyed, the page ID is passed to the mobile data binding business center layer to the corresponding page, and the Rust data layer removes the tag corresponding to the data generic T, because the page ID in the tag can be obtained by + disassembly. When the page ID is found to be consistent with the closed and destroyed page ID, the corresponding tag is removed: list <tag>.remove(index).
[0124] Embodiment 2
[0125] In this example, see Figure 2 , Figure 2 The schematic diagram of another data binding method provided by the embodiment of the present application is shown. Among them, the Rust dynamic link library is loaded at the first time of APP initialization. The Rust dynamic link library is mainly responsible for business processing, data processing, and data caching; the underlying Rust data layer and the target page UI layer are data bound through the data binding business center layer, and the data binding business center layer data structure ViewMap<Tag,View> Among them, the data identification Tag is mainly used to notify the upper layer which View has changed when the underlying Rust data layer data changes. The generation logic of the data identification Tag is page ID + component ID + component hash value; when the UI is initialized, databind = true is set, indicating that the UI component needs to support data binding; when the UI component obtains data for the first time, it passes the data identification Tag to the Rust data layer, and the Rust data layer matches the data value to the Tag. The Rust Tag storage data structure is a key-value pair storage method: Map<Data T, List <tag>>, where the data generic T corresponds to multiple Tags, and each Tag can be considered to correspond to a specific View in the UI layer; after the UI layer first obtains the Rust data layer data and assigns it to the UI, when the Rust data layer data changes, the UI does not need to be refreshed manually or call the code refresh method, and the UI automatically refreshes; the Rust data layer is data-bound to the UI layer through the data binding business center layer; when a certain logic of the Rust data layer triggers a data value change, the Rust data layer will notify the upper-layer data binding business center layer, pass the Tag, and generically give it to the data binding business center layer. The data binding business center layer monitors the data change, obtains the specific View through ViewMap.get(tag), and the View calls the setValue(value) method to refresh the view layer; if a data corresponds to multiple Tags, the list will be traversed in a loop <tag>After each traversal, the Tag is obtained and ViewMap.get(Tag) is called to obtain the specific View. The View calls the setValue(value) method to refresh the view layer. When the page is closed / destroyed, the page ID is passed to the corresponding view in the mobile data binding business center layer. The rust layer removes the Tag corresponding to the data generic T, because the page ID in the Tag can be obtained by + disassembly. If the page ID is found to be consistent with the closed / destroyed page ID, it is removed: list <tag>.remove(index).
[0126] In this embodiment, the underlying Rust dynamic link library is data-bound to the UI layer through the data binding business center layer. When the Rust data layer changes, the Rust data layer will notify the upper data binding business center layer, pass the Tag and generics (data model, basic data type) to the data binding business center layer. When the data binding business center layer monitors the data change, it obtains the specific View through the data structure ViewMap.get(Tag) of the data binding business center layer, and View calls the setValue(value) method to refresh the view layer to realize the real-time change of the underlying data change of the underlying Rust dynamic link library and the UI.
[0127] Embodiment 3
[0128] In this example, see Figure 3 , Figure 3 A schematic diagram of another data binding method of an embodiment of the present application is shown. Among them, the data binding business center layer interacts directly with the UI layer, and the UI actively obtains data and Rust underlying data changes first to the data binding business center layer and then obtains the specific UIView to update the UI; the change data of the underlying Rust layer mainly comes from network layer data changes and local data changes. The network layer data changes mainly include local data and server data synchronization, and the server actively sends data change notifications to the Rust websocket; it can also be data changes caused by local business logic; the Rust data layer has a monitoring business data change layer, including network data changes and local data changes. As long as the data is added, deleted, or modified, the Rust monitoring business data change layer will send a notification to the upper data binding business center layer, and the data binding business center layer will obtain the corresponding view to call the setvalue method.
[0129] Embodiment 4
[0130] In this embodiment, if Figure 4 As shown, Figure 4 A schematic diagram of another data binding method of an embodiment of the present application is shown. Among them, the underlying Rust data layer monitors data changes (addition, deletion, and modification of data). If data changes are detected, the upper data binding business center layer is notified. The specific data structure of the notification includes: tag, data value (generic), data status (1 for new data, 2 for updated data, and 3 for deleted data), and data id is mainly used for listview data update operations; the main responsibility of the data binding business center layer is to monitor the data change notification of the rust data layer, obtain the corresponding view through the tag, and perform operations according to the specific status after successful acquisition. When state == 1, it means addition. If the view is a listview (list component), then the listview.add(value) method is used. If If the view is a common component, the view.setValue(value) method is called; when state == 2, it indicates an update operation. If the view is a listview (list component), the listview.update(id, value) method is called, and if the common component is a listview, the view.setValue(value) method is called; state == 3 indicates a delete operation. If the view is a listview (list component), the listview.remove(id) method is called, and if the common component is a listview, the view.remove() method is called; obtaining the view through the tag mainly comes from the data model ViewMap in the data binding business center layer<Tag,View> , and the View in ViewMap corresponds to the View displayed in the UI layer. The View displayed in the UI layer needs to inherit BaseView, and BaseView provides the setValue method. The value in setValue supports generics, that is, data model model or basic data type. If value == null, the view component will be hidden; BaseView supports listview components, and the listview components in baseview will provide setValue(list[]), addValue(T generic), updateValue(id, T generic), and removeValue(id) methods.
[0131] Embodiment 5
[0132] In this embodiment, if Figure 5 As shown, Figure 5 The schematic diagram of the View component display of the UI layer of the embodiment of the present application is shown. Among them, the View displayed in the UI layer needs to inherit BaseView. Any View can inherit BaseView, including the picture component ImageView. After ImageView inherits BaseView, the setValue method can be called. The new value will be judged whether it is consistent with the original value. If it is consistent, the picture will not be redrawn. If it is inconsistent, the picture will be refreshed; the value can be a binary value or a picture URL address. If it is a URL address, the md5 value of the picture downloaded from the URL will be stored. The basis for judging whether the picture resources are consistent is whether the md5 of the two pictures is consistent.
[0133] Embodiment 6
[0134] In this embodiment, if Figure 6 As shown, Figure 6 A schematic diagram of another data binding method of an embodiment of the present application is shown, which specifically includes a Rust data layer, a data binding business center layer, a data structure definition of a data binding business center layer, communication between the Rust layer and the data binding business center layer, a tag definition, a baseview implementation, and interaction between the data binding business center layer and the baseview.
[0135] In this embodiment, the Rust data layer includes a data monitoring layer and a monitoring feedback data binding business center layer.
[0136] The above Rust data layer is interoperable with the upper data binding business center layer. The main data structure of the Rust layer is Map<Data T, List <tag>>; The data structure of the business center layer of the above data binding is ViewMap<Tag,View> .
[0137] The above-mentioned data business binding center layer is mainly responsible for updating the specific view components in the UI layer after actively acquiring data and updating the specific View components in the UI layer after Rust feedback data changes.
[0138] The above tag is a data identifier, which is used to identify the underlying Rust data layer data changes and notify the upper layer which view has changed. The tag generation logic is page ID + component ID + component hash value.
[0139] In the embodiment of the present invention, the data binding business center layer listens to the data change notification of the Rust data layer, obtains the corresponding View through the Tag, and performs operations according to the specific status after the acquisition is successful. The View obtained through the Tag mainly comes from the data structure ViewMap in the data binding business center layer<Tag,View> , and the View in ViewMap corresponds to the View displayed in the UI layer, and the View displayed in the UI layer needs to inherit baseview.
[0140] The above baseview provides a setValue method. The value in setValue supports generics, that is, data model model or basic data type. If value == null, the view component will be hidden. BaseView supports listview components. The listview components in baseview will provide setValue(list[]), addValue(T generic), updateValue(id, T generic), and removeValue(id) methods.
[0141] In an embodiment of the present invention, the Rust data layer data and the UI layer are data-bound through the data binding business center layer. After the UI layer obtains the Rust layer data for the first time and assigns it to the UI, when the Rust data layer data changes, the Rust data layer will notify the upper data binding business center layer, pass the Tag, generics (data model, basic data type) to the data binding business center layer, and when the data binding business center layer monitors the data change, it obtains the specific View through the data structure ViewMap.get(Tag) of the data binding business center layer, and View calls the setValue(value) method to refresh the view layer. If one data corresponds to multiple Tags, the list will be traversed in a loop. <tag>After each traversal, the Tag is obtained and ViewMap.get(tag) is called to obtain the specific View. The View calls the setValue(value) method to refresh the UI layer. This solves the problem that the terminal application bottom-level data is difficult to bind with the upper-level UI state and the bottom-level data cannot be truly cross-platform. The present invention uses the bottom-level Rust dynamic link library to bind with the UI through the data binding business center layer, so that the bottom-level data changes and the UI changes in real time.
[0142] Embodiment 7
[0143] Corresponding to the above Figure 1 A data binding method shown in Figure 7 The diagram shows a data binding device provided in an embodiment of the present application. The device M70 includes:
[0144] A first loading module M701 is used to load a Rust dynamic link library, wherein the Rust dynamic link library includes a Rust data layer;
[0145] The second loading module M702 is used to load the data binding business center layer;
[0146] The data binding module M703 is used to perform data binding between the Rust data layer in the Rust dynamic link library and the target page UI layer through the data binding business center layer;
[0147] The first processing module M704 is used to monitor the data change in the Rust data layer, and perform corresponding data change operations on the target page UI layer through the data binding business center layer to obtain the changed display page.
[0148] Optional, reference Figure 8 As shown, Figure 8 A schematic diagram of the structure of the second loading module provided in the embodiment of the present application. The second loading module M702 includes:
[0149] The acquisition submodule M7021 is used to acquire the data structure of the data binding business center layer;
[0150] The first processing submodule M7022 is used to obtain the data binding service center layer according to the data structure of the data binding service center layer.
[0151] Optional, reference Fig. 9 As shown, Fig. 9 The schematic diagram of the structure of the acquisition submodule provided in the embodiment of the present application. The acquisition submodule M7021 includes:
[0152] The first acquisition unit M70211 is used to acquire the data identifier of the data binding service center layer;
[0153] The second acquisition unit M70212 is used to acquire multiple page identifiers corresponding to the data representation;
[0154] The processing unit M70213 is used to obtain the data structure of the data binding business center layer according to the data identifier of the data binding business center layer and multiple page identifiers corresponding to the data identifier.
[0155] Optional, reference Fig.10 As shown, Fig.10 This is a schematic diagram of the structure of the first acquisition unit provided in the embodiment of the present application. The first acquisition unit M70211 includes:
[0156] The first acquisition subunit M702111 is used to acquire a page identifier;
[0157] The second acquisition subunit M702112 is used to acquire the component identification;
[0158] The third acquisition subunit M702113 is used to obtain a component hash value;
[0159] The processing subunit M702114 is used to obtain the data identifier of the data binding business center layer according to the page identifier, the component identifier and the component hash value.
[0160] Optional, reference Fig.11 As shown, Fig.11 This is a schematic diagram of another data binding device provided in an embodiment of the present application. The device M70 also includes:
[0161] The setting module M705 is used to support data binding settings for UI components through preset setting rules.
[0162] Optional, reference Fig.12 As shown, Fig.12 A schematic diagram of the structure of the first processing module provided in the embodiment of the present application. The first processing module M704 includes:
[0163] The second processing submodule M7041 is used to monitor the addition of data in the Rust data layer, and perform a corresponding data addition operation on the UI layer through the data binding business center layer to obtain a first display page after the data is added;
[0164] The third processing submodule M7042 is used to monitor the data deletion in the Rust data layer, and perform the corresponding data deletion operation on the UI layer through the data binding business center layer to obtain the second display page after the data is deleted.
[0165] The fourth processing submodule M7043 is used to monitor the data update in the Rust data layer, and perform corresponding data update operations on the UI layer through the data binding business center layer to obtain a third display page after the data is updated.
[0166] Optional, reference Fig.13 As shown, Fig.13 This is a schematic diagram of another data binding device provided in an embodiment of the present application. The device M70 also includes:
[0167] The second processing module M706 is used to transmit the page identifier to move the corresponding page in the data binding business center layer when monitoring the page destruction, and the Rust data layer removes the corresponding data identifier.
[0168] Embodiment 8
[0169] Fig.14 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.14 As shown, the electronic device D14 of this embodiment includes: at least one processor D140 ( Fig.14 Only one is shown), memory D141, network interface D142, and a computer program stored in memory D141 and executable on at least one processor D140. The processor D140 is used to call the computer program stored in memory D141 and execute the following steps:
[0170] Loading a Rust dynamic link library, wherein the Rust dynamic link library includes a Rust data layer;
[0171] Load the data binding business center layer;
[0172] Data binding is performed between the Rust data layer in the Rust dynamic link library and the target page UI layer through the data binding business center layer;
[0173] When data changes in the Rust data layer are monitored, corresponding data change operations are performed on the target page UI layer through the data binding business center layer to obtain a changed display page.
[0174] Optionally, the loading data binding service center layer executed by the processor D140 includes:
[0175] Get the data structure of the data binding business center layer;
[0176] According to the data structure of the data binding service center layer, a data binding service center layer is obtained.
[0177] Optionally, the obtaining of the data structure of the data binding service center layer performed by the processor D140 includes:
[0178] Get the data identifier of the data binding business center layer;
[0179] Acquire multiple page identifiers corresponding to the data representation;
[0180] The data structure of the data binding service center layer is obtained according to the data identifier of the data binding service center layer and a plurality of page identifiers corresponding to the data identifier.
[0181] Optionally, the obtaining of the data identifier of the data binding service center layer performed by the processor D140 includes:
[0182] Get the page ID;
[0183] Get component ID;
[0184] Get component hash value;
[0185] A data identifier of a data binding business center layer is obtained according to the page identifier, the component identifier and the component hash value.
[0186] Optionally, before the step of data binding the Rust data layer in the Rust database with the UI layer through the data binding business center layer, the method executed by the processor D140 further includes:
[0187] Support data binding settings for UI components through preset setting rules.
[0188] Optionally, when the monitoring of data changes in the Rust data layer executed by the processor D140 is detected, a corresponding data change operation is performed on the UI layer through the data binding business center layer to obtain an updated display page, including:
[0189] When new data is detected in the Rust data layer, the corresponding data addition operation is performed on the UI layer through the data binding business center layer to obtain the first display page after the data is added;
[0190] When data deletion is detected in the Rust data layer, the corresponding data deletion operation is performed on the UI layer through the data binding business center layer to obtain the second display page after data deletion.
[0191] When data update in the Rust data layer is monitored, a corresponding data update operation is performed on the UI layer through the data binding business center layer to obtain a third display page after the data is updated.
[0192] Optionally, after the step of performing a corresponding data change operation on the UI layer through the data binding business center layer when data changes in the Rust data layer are monitored, the method executed by the processor D140 further includes:
[0193] When the page destruction is detected, the page identifier is passed to move the corresponding page in the data binding business center layer, and the Rust data layer removes the corresponding data identifier.
[0194] The electronic device D14 provided in the embodiment of the present invention can implement various implementation methods in an embodiment of a data binding method, as well as corresponding beneficial effects, which will not be described again here to avoid repetition.
[0195] The electronic device provided by the embodiment of the present invention can implement each process implemented by the data binding method in the above method embodiment and can achieve the same beneficial effect. To avoid repetition, it will not be described here.
[0196] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by the processor D140, the various processes of a data binding method embodiment provided in an embodiment of the present application are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0197] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any updates, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.< / tag> < / tag> < / tag> < / tag> < / tag> < / tag> < / tag> < / tag> < / tag>
Claims
1. A data binding method, characterized in that: The following steps are involved: Load the Rust dynamic link library, which includes the Rust data layer. The Rust dynamic link library is responsible for business processing, data processing, and data caching. The app data cache is placed in the dynamic link library. The Rust data layer is used to monitor the business data change layer. The business data change layer includes network data changes and local data changes. The network data changes include synchronization of local data and server data. Loading a data binding business center layer, the data binding business center layer includes a data structure of the data binding business center layer, the data structure includes a data identifier and a plurality of page identifiers corresponding to the data identifier, the data identifier includes a page identifier, a component identifier and a component hash value; The Rust data layer in the Rust dynamic link library is data-bound with the target page UI layer through the data binding business center layer, and the data binding business center layer monitors the data change notification of the Rust data layer; When data changes in the Rust data layer are monitored, corresponding data change operations are performed on the target page UI layer through the data binding business center layer to obtain a changed display page.
2. The data binding method according to claim 1, characterized in that: The loading data binding business center layer includes: Get the data structure of the data binding business center layer; According to the data structure of the data binding service center layer, a data binding service center layer is obtained.
3. The data binding method according to claim 2, characterized in that: The method of obtaining the data structure of the data binding service center layer includes: Get the data identifier of the data binding business center layer; Obtain multiple page identifiers corresponding to the data identifier; The data structure of the data binding service center layer is obtained according to the data identifier of the data binding service center layer and a plurality of page identifiers corresponding to the data identifier.
4. The data binding method according to claim 3, characterized in that: The step of obtaining the data identifier of the data binding service center layer includes: Get the page ID; Get component ID; Get component hash value; A data identifier of a data binding business center layer is obtained according to the page identifier, the component identifier and the component hash value.
5. The data binding method according to claim 4, characterized in that: Before the step of data binding the Rust data layer in the Rust database with the UI layer through the data binding business center layer, the method further includes: Support data binding settings for UI components through preset setting rules.
6. The data binding method according to claim 5, characterized in that: When the data change in the Rust data layer is monitored, the corresponding data change operation is performed on the UI layer through the data binding business center layer to obtain an updated display page, including: When new data is detected in the Rust data layer, the corresponding data addition operation is performed on the UI layer through the data binding business center layer to obtain the first display page after the data is added; When data deletion is detected in the Rust data layer, the corresponding data deletion operation is performed on the UI layer through the data binding business center layer to obtain the second display page after data deletion. When data update in the Rust data layer is monitored, a corresponding data update operation is performed on the UI layer through the data binding business center layer to obtain a third display page after the data is updated.
7. The data binding method according to claim 6, characterized in that: After the step of performing a corresponding data change operation on the UI layer through the data binding business center layer when the data change in the Rust data layer is monitored, the method further includes: When the page destruction is detected, the page identifier is passed to move the corresponding page in the data binding business center layer, and the Rust data layer removes the corresponding data identifier.
8. A data binding device, characterized in that: include: The first loading module is used to load the Rust dynamic link library, which includes the Rust data layer. The Rust dynamic link library is responsible for business processing, data processing, and data caching. The app data cache is placed in the dynamic link library. The Rust data layer is used to monitor the business data change layer. The business data change layer includes network data changes and local data changes. The network data changes include synchronization of local data and server data; A second loading module is used to load a data binding business center layer, wherein the data binding business center layer includes a data structure of the data binding business center layer, wherein the data structure includes a data identifier and a plurality of page identifiers corresponding to the data identifier, wherein the data identifier includes a page identifier, a component identifier, and a component hash value; A data binding module, used to perform data binding between the Rust data layer in the Rust dynamic link library and the target page UI layer through the data binding business center layer, and the data binding business center layer monitors data change notifications of the Rust data layer; The first processing module is used to monitor the data change in the Rust data layer, and perform corresponding data change operations on the target page UI layer through the data binding business center layer to obtain the changed display page.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that: When the processor executes the computer program, the data binding method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, a data binding method as claimed in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Page process control method and device, electronic equipment and storage medium
CN115033315A