Data binding method, device, equipment and medium based on MVVM pattern

By using the binding signal class to encapsulate the system interface event class in the iOS system, the two-way binding process of views and view models is simplified, the problems of lengthy call stacks and complex memory management are solved, and memory management performance is improved.

CN115016786BActive Publication Date: 2025-09-30DOUYIN VISION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210161337.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-22
Publication Date
2025-09-30
Estimated Expiration
2042-02-22

AI Technical Summary

Technical Problem

In the iOS system, when the existing technology uses the ReactiveCocoa framework to implement the data binding mechanism of the MVVM model, it leads to lengthy call stacks and complex memory management, which is prone to problems.

Method used

By calling the system interface event class through the binding signal class, the view and the view model are bidirectionally bound. The binding signal class encapsulates the system interface event class, simplifies the bidirectional binding process of the view and the view model, and avoids the lengthy call stack in responsive programming.

Benefits of technology

It implements quick two-way binding between views and view models, reduces memory management complexity and improves performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115016786B_ABST
    Figure CN115016786B_ABST
Patent Text Reader

Abstract

The disclosed embodiments relate to a data binding method, apparatus, device, and medium based on the MVVM pattern. The method comprises: determining a view and view model to be bound; and bidirectionally binding the view and view model by invoking a system interface event class via a binding signal class. The binding signal class encapsulates the system interface event class, which is a system class of a preset operating system. Using the above technical solution, a fast bidirectional binding mechanism between the view and view model can be implemented by encapsulating the binding signal class that encapsulates the system interface event class. Because the mechanism used in responsive programming is not required, a lengthy call stack is avoided, complexity is reduced, and memory management performance is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a data binding method, apparatus, device, and medium based on the MVVM pattern. Background Art

[0002] The Model-View-Viewmodel (MVVM) pattern is a design pattern that evolved from the Model-View-Controller (MVC) pattern. It is an architectural pattern based on front-end development. This pattern requires a two-way data binding mechanism to improve development efficiency.

[0003] In the related art, the ReactiveCocoa (RAC) framework is usually used in the iOS system to implement the above-mentioned binding mechanism. However, the RAC framework is a Functional Reactive Programming (FRP) framework, which needs to implement mechanisms in responsive programming such as event streams and hot and cold signals. In order to implement these mechanisms, more code needs to be encapsulated when implementing the above-mentioned binding mechanism, which leads to a lengthy call stack, which in turn makes memory management complex and prone to problems. Summary of the Invention

[0004] In order to solve the above technical problems, the present disclosure provides a data binding method, apparatus, device and medium based on the MVVM pattern.

[0005] The present disclosure provides a data binding method based on the MVVM pattern, the method comprising:

[0006] Determine the view and view model to be bound;

[0007] The system interface event class is called by the binding signal class to perform bidirectional binding between the view and the view model, wherein the system interface event class is encapsulated in the binding signal class, and the system interface event class is a system class of a preset operating system.

[0008] The present disclosure also provides a data binding device based on the MVVM pattern, the device comprising:

[0009] Determination module, used to determine the view and view model to be bound;

[0010] The binding module is used to call the system interface event class through the binding signal class to perform two-way binding between the view and the view model, wherein the binding signal class encapsulates the system interface event class, and the system interface event class is a system class of the preset operating system.

[0011] An embodiment of the present disclosure also provides an electronic device, comprising: a processor; a memory for storing instructions executable by the processor; the processor for reading the executable instructions from the memory and executing the instructions to implement a data binding method based on the MVVM pattern as provided in an embodiment of the present disclosure.

[0012] An embodiment of the present disclosure further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is used to execute the data binding method based on the MVVM pattern as provided in the embodiment of the present disclosure.

[0013] The technical solution provided by the disclosed embodiments has the following advantages over existing technologies: The disclosed embodiments provide a data binding solution based on the MVVM pattern, which determines the view and view model to be bound; bidirectionally binds the view and view model by calling the system interface event class via a binding signal class, wherein the binding signal class encapsulates the system interface event class, which is a system class of the preset operating system. Using this technical solution, a fast bidirectional binding mechanism between views and view models can be implemented through the binding signal class that encapsulates the system interface event class. Because the mechanisms used in responsive programming do not need to be implemented, a lengthy call stack is avoided, complexity is reduced, and memory management performance is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.

[0015] Figure 1 A flow chart of a data binding method based on the MVVM pattern provided in an embodiment of the present disclosure;

[0016] Figure 2 A schematic diagram of a packaging of a binding signal class provided in an embodiment of the present disclosure;

[0017] Figure 3 A schematic diagram of a user interface provided in an embodiment of the present disclosure;

[0018] Figure 4 A schematic diagram of the structure of a data binding device based on the MVVM pattern provided in an embodiment of the present disclosure;

[0019] Figure 5 A schematic structural diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0020] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.

[0021] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0022] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.

[0023] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0024] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".

[0025] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0026] In order to solve the problems of long call stack and abnormal memory management in related technologies, the embodiments of the present disclosure provide a data binding method based on the MVVM pattern, which is introduced below in conjunction with specific embodiments.

[0027] Figure 1 A flow chart of a data binding method based on the MVVM pattern provided in an embodiment of the present disclosure is provided. The method can be executed by a data binding device based on the MVVM pattern, wherein the device can be implemented using software and / or hardware and can generally be integrated into an electronic device.

[0028] like Figure 1 As shown, the method includes:

[0029] Step 101: Determine the view and view model to be bound.

[0030] The view can be understood as the object used in the MVVM pattern to encapsulate the user interface and its logic; it can be the structure, layout, and appearance that users see on the screen. The view model can be understood as an abstraction of the view in the MVVM pattern, exposing public properties and commands. The binder within it facilitates communication between the view and the model, coordinating the view's interaction with any required models. The model described above can be an object used in the MVVM pattern to encapsulate the application's business logic and related data, representing the content's data access layer.

[0031] The MVVM pattern can be composed of the three parts mentioned above: view, model, and viewmodel. The view can be independent of model changes and modifications. There is no direct connection between the view and model, but rather interaction through the viewmodel. The interaction between the model and viewmodel is bidirectional: changes in the view are synchronized with the model, and changes in the model are immediately reflected in the view. In the MVVM pattern, the view can interact with the viewmodel through data binding and command lines, and change event notifications. The viewmodel queries, observes, and coordinates model updates, conversions, validation, and aggregation of data for display in the view.

[0032] In the disclosed embodiments, a data binding device based on the MVVM pattern (hereinafter referred to as the data binding device) can determine the views and view models that require bidirectional binding based on the business logic requirements of the application on the user interface. A view model can be bound to multiple views. The disclosed embodiments are not limited to the type of application; for example, the application can be a video program, a reading program, etc.

[0033] For example, when an application needs to implement a login button on the login page that is not clickable when the account input box or password input box is empty, the view to be bound may include a first view that encapsulates the text events of the account input box and the password input box, and the view model to be bound may include a first view model that observes the state of the first view and updates the state changes to the model data; the view to be bound also includes a second view that encapsulates the click event of the login button, and the view model to be bound also includes a second view model that synchronizes the update status of the data on the model to the second view, so that the second view displays whether the login button is clickable.

[0034] Step 102: Call the system interface event class through the binding signal class to perform bidirectional binding between the view and the view model. The binding signal class encapsulates the system interface event class, and the system interface event class presets the system class of the operating system.

[0035] The BindingSignal class can be a framework or mechanism newly added to the disclosed embodiment to simply serve the above-mentioned MVVM pattern. The BindingSignal class can support the core signal class mechanism of the RAC framework. Its implementation is a class cluster implementation, including the implementation of multiple subclasses. The BindingSignal class can encapsulate the system interface event class so that when used, there is no need to care about the specific implementation of the system interface event class, and the interface of the BindingSignal class can be directly called.

[0036] The system interface event class may be a system class in a preset operating system, which is used to control events and logic of the user interface. The preset operating system may be an iOS operating system. In the embodiment of the present disclosure, the system interface event class may include an interface control class, an attribute detection class, and an event gesture class. Among them, the interface control class (UIControl) may be understood as a class for performing user interface control, the attribute detection class (Key-Value Observing, KVO) may be used to detect changes in object attributes and respond quickly, that is, the attribute detection class may observe a certain attribute of an object, and if the attribute changes, a notification may be obtained and a response may be made. The event gesture class may be a class of gestures for a class of events in a preset operating system. Event gestures may include tapping, swiping, long pressing, etc. For example, UITapGestureRecognizer represents a tap gesture.

[0037] In some embodiments, calling the system interface event class through the binding signal class to perform bidirectional binding between the view and the view model may include: calling the interface control class through the binding signal class to encapsulate the view to be bound as a first binding signal and the view model as a second binding signal; calling the property detection class and the event gesture class through the binding signal class to perform bidirectional binding between the first binding signal and the second binding signal.

[0038] Specifically, when the data binding device performs bidirectional binding on the view and the view model, it can first call the interface control class through the binding signal class to encapsulate the view to be bound as a first binding signal, and create an instance of the view model to be bound, and encapsulate the view model as a second binding signal. The above-mentioned first binding signal and second binding signal are both signals that comply with its rules under the framework of the binding signal class; thereafter, the attribute detection class and the event gesture class can be respectively called through the binding signal class to perform bidirectional binding on the first binding signal and the second binding signal, that is, to realize the bidirectional binding of the view and the view model. The bidirectional binding process can be implemented through simple code, and the process of bidirectional binding between the attribute detection class and the event gesture class can be the same as the process implemented through the RAC framework in the related technology, which will not be repeated here.

[0039] In some embodiments, the code for executing two-way binding is located in and executed by the main thread. The code for executing two-way binding can be understood as the code that executes the steps of calling the attribute detection class and the event gesture class through the binding signal class to perform two-way binding of the first binding signal and the second binding signal.

[0040] In related technologies, when implementing two-way binding logic through the RAC framework, due to the long call stack, the executed code needs to be executed in different threads, which can cause multi-threaded execution to be unsafe. However, the binding signal class of this application is dedicated to two-way binding between views and view models. By placing all two-way binding code in the main thread for execution, thread safety can be guaranteed.

[0041] The disclosed embodiments provide a data binding solution based on the MVVM pattern, which determines the view and view model to be bound. The binding signal class calls the system interface event class to perform a two-way binding between the view and the view model. The binding signal class encapsulates the system interface event class, which is a system class pre-set to the operating system. This technical solution enables a fast two-way binding mechanism between the view and the view model through the binding signal class that encapsulates the system interface event class. This eliminates the need to implement responsive programming mechanisms, avoids lengthy call stacks, reduces complexity, and improves memory management performance.

[0042] In some embodiments, after bidirectionally binding a view to a view model, the data binding method based on the MVVM pattern further includes: synchronizing the changed state of the view to the view model when the user interface state corresponding to the view changes; and / or synchronizing the changed state of the view model to the view when the data corresponding to the view model changes. Optionally, the changed state between the view and the view model is synchronized via subscription.

[0043] The data corresponding to the view model can be data encapsulated in a model that can interact with it bidirectionally. After the view and the view model are bidirectionally bound, the states of the view and the view model will be synchronized, and the state of the view and the model that can interact with the view model will also be synchronized. Specifically, the synchronization of changing states can be achieved through subscription. A subscriber can be registered for the user interface state corresponding to the view. When the user interface state corresponding to the view changes, the subscriber can be notified, and then the changed state of the view can be synchronized to the view model through the subscriber. Similarly, when the data corresponding to the view model changes, the changed state of the data (that is, the changed state of the view model) can be synchronized to the view.

[0044] In some embodiments, the binding signal class encapsulates the system interface event class through an intermediate event class. The binding signal class is a class cluster including multiple subclasses, and the system interface event class is a subclass of the binding signal class. The intermediate event class can be a customized event class that complies with the rules of the binding signal class framework.

[0045] For example, Figure 2 A schematic diagram of a packaging of a binding signal class provided by an embodiment of the present disclosure, such as Figure 2 As shown in the figure, a schematic diagram of the encapsulation of the binding signal class is shown. The interface control class, attribute detection class and event gesture class of the last layer in the figure are the system interface control class in the iOS operating system. The specific encapsulation process may include: abstracting the interface control class, attribute detection class and event gesture class of the iOS operating system into a custom intermediate event class (not shown in the figure), and then converting the abstract intermediate event classes into binding signals of the framework of the binding signal class, that is, obtaining the interface control class, attribute detection class and event gesture class of the binding signal of the second layer in the figure. These binding signals are subclasses of the binding signal class.

[0046] After encapsulating the Binding Signal class, you can implement related functions by calling the parent class interface without having to worry about the specific implementation of several subclasses of the System Interface Control class. Optionally, if you need to support more system event scenarios, you can implement a new subclass of the Binding Signal class, that is, encapsulate the new subclass in the Binding Signal class.

[0047] In the above solution, by using the system interface control class in the iOS operating system as the basis for upper-level encapsulation, the convenience and completeness of the RAC framework in related technologies can be achieved. Since there is no need to implement responsive programming, the call stack can be greatly shortened and there is no problem of memory management exceptions.

[0048] Next, a specific example is used to further illustrate the data binding method based on the MVVM pattern in the embodiment of the present disclosure. For example, Figure 3 A schematic diagram of a user interface provided in an embodiment of the present disclosure is provided. Figure 3The following example shows a login page with an account input field, a password input field, and a login button. A business requirement might be to disable the login button on the login page when either the account input field or the password input field is empty. To achieve this requirement, you need to monitor the text state of a UITextField and assign it to the corresponding property of the view model in real time. This property then notifies the login button of the corresponding view model property to indicate whether it is clickable or unclickable. A UITextField represents the text state of the account input field and the password input field. The corresponding property of the view model can refer to a property of the model that interacts bidirectionally with the view model. Using the aforementioned binding signal class, you can quickly and easily bind the text state of the UITextField to the view and view model properties, or from the view to the view model. Specifically, by calling the interface of the binding signal class, you can bind the text event of the account input field to the name property of the view model, and the text event of the password input field to the password property of the view model. After binding, changes in the text content of the account input field are synchronized to the name property of the view model, and changes in the text content of the password input field are synchronized to the password property of the view model.

[0049] Optionally, the above-mentioned binding signal class can also be used to merge the binding signals of the name and password property changes in the view model into one signal and subscribe to it; then the merged signal of the view model can be bound to the response event of the login button, and the binding can be from the view model to the view. After binding, when the name and password properties in the view model change, that is, when the length of both properties is not 0, the login button can be set to be clickable; otherwise, the login button can be set to not clickable.

[0050] The observer macros in the bound signal class are similar to those in the core signal class of the RAC framework in related art, except that they return a bound signal instance. The bound signal class framework also provides implementations of many higher-order functions, such as the aforementioned ability to compress two signal instances into one, where any new event streams from either instance are notified to the subscriber. Therefore, the bound signal class achieves the same convenience and completeness as the core signal class in the RAC framework in related art.

[0051] In this solution, with the two-way binding framework of the MVVM model as the purpose, by only encapsulating the system interface control class of the iOS operating system, it is possible to provide an implementation of a program interface similar to the RAC framework in the related technology. This ensures that the experience of using it in the MVVM scenario is consistent with that of RAC, and reduces the call stack and complexity. At the same time, it ensures that the probability of memory management exceptions is reduced, and provides a very convenient program interface to support the implementation of the MVVM model on the client side of the iOS operating system.

[0052] Figure 4 This is a schematic diagram of the structure of a data binding device based on the MVVM pattern provided by an embodiment of the present disclosure. The device can be implemented by software and / or hardware and can generally be integrated into an electronic device. Figure 4 As shown, the device includes:

[0053] Determining module 401, used to determine the view and view model to be bound;

[0054] The binding module 402 is used to call the system interface event class through the binding signal class to perform two-way binding between the view and the view model, wherein the binding signal class encapsulates the system interface event class, and the system interface event class is a system class of the preset operating system.

[0055] Optionally, the system interface event class includes an interface control class, an attribute detection class, and an event gesture class.

[0056] Optionally, the binding module 402 is specifically configured to:

[0057] Calling the interface control class through the binding signal class, encapsulating the view to be bound as a first binding signal and encapsulating the view model as a second binding signal;

[0058] The attribute detection class and the event gesture class are called through the binding signal class to perform bidirectional binding on the first binding signal and the second binding signal.

[0059] Optionally, the device further includes a synchronization module, which is used to: after bidirectionally binding the view and the view model,

[0060] When the user interface state corresponding to the view changes, the changed state of the view is synchronized to the view model;

[0061] And / or, when the data corresponding to the view model changes, the data change state of the view model is synchronized to the view.

[0062] Optionally, the change status between the view and the view model is synchronized by subscription.

[0063] Optionally, the binding signal class encapsulates the system interface event class through an intermediate event class. The binding signal class is a class cluster including multiple subclasses, and the system interface event class is a subclass of the binding signal class.

[0064] Optionally, the execution code of the two-way binding is located in the main thread and executed by the main thread.

[0065] The data binding device based on the MVVM pattern provided in the embodiments of the present disclosure can execute the data binding method based on the MVVM pattern provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.

[0066] The embodiments of the present disclosure further provide a computer program product, including a computer program / instruction, which, when executed by a processor, implements the data binding method based on the MVVM pattern provided by any embodiment of the present disclosure.

[0067] Figure 5 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 5 , which shows a schematic structural diagram of an electronic device 500 suitable for implementing the embodiments of the present disclosure. The electronic device 500 in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.

[0068] like Figure 5 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. Various programs and data required for the operation of the electronic device 500 are also stored in the RAM 503. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0069] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.

[0070] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the data binding method based on the MVVM pattern of the embodiment of the present disclosure are executed.

[0071] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.

[0072] In some embodiments, the client and server can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0073] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0074] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: determines the view and view model to be bound; calls the system interface event class through the binding signal class to bidirectionally bind the view and the view model, wherein the binding signal class encapsulates the system interface event class, and the system interface event class is a system class of the preset operating system.

[0075] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0076] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0077] The units involved in the embodiments described in this disclosure may be implemented in software or hardware, wherein the name of a unit does not necessarily limit the unit itself.

[0078] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.

[0079] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0080] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.

[0081] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0082] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.

Claims

1. A data binding method based on the MVVM pattern, characterized in that: include: Determine the view and view model to be bound; The view and the view model are bidirectionally bound by calling the system interface event class through the binding signal class, wherein the system interface event class is encapsulated in the binding signal class. The system interface event class is a system class of a preset operating system, and the system interface event class includes an interface control class, a property detection class, and an event gesture class; The calling of the system interface event class by the binding signal class to perform bidirectional binding between the view and the view model includes: Calling the interface control class through the binding signal class, encapsulating the view to be bound as a first binding signal and encapsulating the view model as a second binding signal; The attribute detection class and the event gesture class are called through the binding signal class to perform bidirectional binding on the first binding signal and the second binding signal.

2. The method according to claim 1, characterized in that After bidirectionally binding the view to the view model, the method further includes: When the user interface state corresponding to the view changes, the changed state of the view is synchronized to the view model; And / or, when the data corresponding to the view model changes, the data change state of the view model is synchronized to the view.

3. The method according to claim 2, characterized in that The change status between the view and the view model is synchronized through subscription.

4. The method according to claim 1, wherein The binding signal class encapsulates the system interface event class through an intermediate event class. The binding signal class is a class cluster including multiple subclasses. The system interface event class is a subclass of the binding signal class.

5. The method according to claim 1, wherein The execution code of the two-way binding is located in the main thread and is executed by the main thread.

6. A data binding device based on the MVVM pattern, characterized in that: include: Determination module, used to determine the view and view model to be bound; A binding module, configured to call a system interface event class through a binding signal class to perform bidirectional binding between the view and the view model, wherein the binding signal class encapsulates the system interface event class, which is a system class of a preset operating system and includes an interface control class, a property detection class, and an event gesture class; The calling of the system interface event class by the binding signal class to perform bidirectional binding between the view and the view model includes: Calling the interface control class through the binding signal class, encapsulating the view to be bound as a first binding signal and encapsulating the view model as a second binding signal; The attribute detection class and the event gesture class are called through the binding signal class to perform bidirectional binding on the first binding signal and the second binding signal.

7. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the data binding method based on the MVVM pattern described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that The storage medium stores a computer program, and the computer program is used to execute the data binding method based on the MVVM pattern as described in any one of claims 1 to 5.