Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. However, the exemplary embodiments can be embodied in many different forms and should not be construed as limited to the examples set forth herein, but rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the application. One skilled in the relevant art will recognize, however, that the application may be practiced without one or more of the specific details, or with other methods, components, devices, steps, etc. In other instances, well-known methods, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the application.
In the present embodiment, the term "module" or "unit" refers to a computer program or a part of a computer program having a predetermined function and working together with other relevant parts to achieve a predetermined object, and may be implemented in whole or in part by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Also, a processor (or multiple processors or memories) may be used to implement one or more modules or units. Furthermore, each module or unit may be part of an overall module or unit that incorporates the functionality of the module or unit.
The block diagrams depicted in the figures are merely functional entities and do not necessarily correspond to physically separate entities. That is, the functional entities may be implemented in software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices.
The flow diagrams depicted in the figures are exemplary only, and do not necessarily include all of the elements and operations/steps, nor must they be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the order of actual execution may be changed according to actual situations.
Fig. 1 shows a block diagram of an exemplary system architecture to which the technical solution of the present application is applied.
As shown in fig. 1, system architecture 100 may include a terminal device 110, a network 120, and a server 130. Terminal device 110 may include various electronic devices such as smart phones, tablet computers, notebook computers, desktop smart speakers, smart wearable devices, smart vehicle devices, smart payment terminals, and the like. The server 130 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, basic cloud computing services such as big data and artificial intelligence platforms, and the like. Network 120 may be a communication medium of various connection types capable of providing a communication link between terminal device 110 and server 130, and may be, for example, a wired communication link or a wireless communication link.
The system architecture in embodiments of the present application may have any number of terminal devices, networks, and servers, as desired for implementation. For example, the server 130 may be a server group composed of a plurality of server devices. In addition, the technical solution provided in the embodiment of the present application may be executed by the terminal device 110, or may be implemented by the terminal device 110 and the server 130 together, which is not limited in particular by the present application.
Fig. 2 shows an application scenario of the method for executing page interaction by a terminal device according to an embodiment of the present application.
As shown in fig. 2, in the application scenario, the terminal device is a smart phone held by a user, and various application clients, such as instant messaging software, audio/video playing software, online shopping software, network payment software, and the like, can be installed on the terminal device. In order to realize various application functions of the application program, a plurality of functional modules can be configured inside the application program, and a complete interaction event processing flow can be realized through mutual collaboration among the functional modules. Wherein each functional module may be responsible for executing one or more data processing links.
Via the interactive interface of the terminal equipment, the view pages of various application programs can be presented to the user, and the interactive operation of the user can be accepted, so that the display content and the display effect of the view pages can be adjusted according to the interactive operation.
As shown in fig. 2, in the application scenario, the interactive interface of the terminal device may implement an interactive function through a plurality of functional modules such as a view 201, a view controller 202, and a view model 203.
View 201 refers to the presentation layer of the interactive interface that is responsible for exposing data from the view model and collecting user input. View 201 does not contain business logic, but rather connects the data in the view model with the elements presented on the interactive interface by data binding. View 201 is responsible for receiving user interactions, such as clicking on a button, entering text, etc., which may trigger corresponding data processing commands defined in the view model and used to execute the corresponding business logic. Since view 201 does not contain business logic, it can be more easily reused in different applications or contexts, and view 201 can be more easily unit tested due to its simplicity and separation from business logic.
View controller 202 is a functional module responsible for managing the interaction process between view 201 and view model 203. View controller 202 typically creates and initializes a view model at view loading, responsible for instantiating and passing the view model to the view. The view controller 202 is also responsible for setting data bindings between views and view models, including, for example, user interface elements that bind attributes of the view model to the views, and data processing commands that bind interaction events (e.g., button click events) of the views to the view model. The view controller 202 may manage the full lifecycle of the views, including creation, display, hiding, and destruction of the views.
View model 203 serves as a bridge between views and models, and the main purpose is to separate business logic and data processing from view layers, making the views more compact and manageable. View model 203 contains business logic associated with the user interface that is responsible for handling the acquisition, processing, and updating of data, as well as the response to user interactions. The view model 203 provides the data needed for the view, which can be automatically updated into the view by a data binding mechanism. When changes occur to the data in the view model 203, the view will automatically update to reflect these changes. View model 203 is also responsible for converting the data in the model into a format that the view can understand and display, possibly including data formatting, unit conversion, and so forth. View model 203 decouples the views from the model so that the views can be developed and tested independent of business logic, while also allowing the model to be developed independent of the user interface.
In some alternative embodiments, the view model 203 may store the data in a locally stored database of the terminal device, or may store the data in a remote database of the server. When the data is stored on the server, the view model 203 may be in network communication with the server to obtain the data from the server.
When a user triggers an interaction operation on the interaction interface through view 201, view controller 202 may process the user's interactions with view 201 and forward these interactions to view model 203. For example, when a user clicks a button, the view controller 202 invokes a corresponding data processing command in the view model 203, and after completing a data processing process based on the data processing command, the data processing result is displayed to the user through the view 201.
In the technical solution provided in the embodiment of the present application, the first data channel 204 corresponding to the current view page may be created through the view model 203, and each functional module may transfer data between different data processing links through the first data channel 204. A data channel, which may be referred to as a pipeline, is a data-streaming architecture in which data is transmitted through a series of processing steps or stages, each of which may process a different portion of the data in parallel. The data channel allows data to flow between different processing units without waiting for all operations to be completed by the previous processing unit.
Taking the example of an online shopping application, the application has a complex interactive interface that allows the user to browse items, view details, add to the shopping cart, and make purchases.
When a user clicks on an item on the interactive interface, the clicking action is an interactive event that triggers the following sequence of operations.
The writing of the first attribute data the view 201 captures the interaction event of the user clicking on the merchandise and generates the first attribute data which may include information such as the ID of the merchandise, the timestamp of the user click, the type of device clicked, etc. This information is written to the first data channel 204 for transfer between the different data processing links of the application.
Sending of data acquisition request the view model 203 sends a data acquisition request to the server requesting to acquire detailed information related to the commodity clicked by the user, such as commodity description, price, stock status, etc.
And receiving the second attribute data and updating the page content, namely sending detailed information of the commodity back to the view model 203 as the second attribute data after the server processes the request. When the data arrives at the view 201 through the first data channel 204, the view 201 updates the page content presented on the interactive interface according to the second attribute data. For example, the product detail page may show information such as a high definition picture, detailed description, user rating, etc. of the product.
The page interaction method, the page interaction device, the computer readable medium, the electronic device and the computer program product provided by the application are described in detail below with reference to the specific embodiments.
Fig. 3 shows a flow chart of a page interaction method in an embodiment of the application, which may be performed by the terminal device shown in fig. 1 or may be performed jointly by the terminal device and the server. The embodiment of the application is described by taking a page interaction method executed by terminal equipment as an example. As shown in fig. 3, the page interaction method may include the following steps S310 to S330.
And S310, writing first attribute data into a first data channel according to an interaction event triggered on the interaction interface, wherein the interaction event comprises a plurality of data processing links, the first data channel is used for transmitting data among different data processing links, and the first attribute data is used for representing attribute change information generated by the interaction interface at an initiating link of the interaction event.
An interactive interface refers to an interface through which information is exchanged between a user and a terminal device, and may include a Graphical User Interface (GUI), a Command Line Interface (CLI), a Conversational User Interface (CUI), or the like. The interaction event includes an operation performed by the user on the interaction interface, such as clicking, sliding, entering text, and so forth.
When a user uses the application software on the terminal device, the terminal device presents a view page of the application software to the user through the interactive interface, and meanwhile, can receive interactive operations executed by the user on the view page of the application software through the interactive interface.
For example, functionality controls for implementing different operational functions, such as virtual buttons, input boxes, or sliding wheels, etc., are typically distributed on view pages of application software. In addition, interface elements for carrying different media contents, such as video, audio, pictures or texts, etc., are distributed on the view page.
The user performs interactive operations such as clicking, sliding and the like on the interactive interface, and can interact with the functional controls or interface elements distributed on the view page to initiate corresponding interactive events. Triggering of the interaction event will cause a corresponding change in the attribute of the interaction interface, which may include a change in the view presentation content or a change in the view presentation effect on the interaction interface. For example, one view page displayed on the interactive interface jumps to another view page, shows the animation effect of the page jump, the animation effect of the current page closing and the animation effect of the new page loading, adjusts the size of the current page, and so on.
In the initiation link of the interaction event, attribute change information of the interaction interface can be collected to obtain first attribute data, and the first attribute data is further written into the first data channel. So that the first attribute data can be passed on to the next data processing link.
In one embodiment of the application, two adjacent data processing elements may be executed on the same functional module or may be executed on different functional modules.
For example, one interaction event may include an initiation link, a response link, and a presentation link. Taking the plurality of functional modules shown in fig. 2 as an example, the initiating link of the interaction event may include receiving, through the view 201, an interaction operation triggered by a user, the responding link may include converting, through the view controller 202, the interaction operation received by the view 201 into an executable operation command, and executing the operation command through the view model 203 to obtain response data for responding to the interaction operation from a data source, and the presenting link may include converting, through the view controller 202, the response data obtained by the view model 203 into presentable content data, and presenting, through the view 201, a view page containing the above content data on the interaction interface.
And S320, sending a data acquisition request to a data source, wherein the data acquisition request is used for requesting to acquire data responding to the first attribute data.
A data source refers to a system, device or service unit that stores data, and may be, for example, a database, a file system, an API interface, etc. The data source defines location information of the data, user authentication information, and configuration required for interaction with the data. The data source in the embodiment of the application can comprise a database configured locally at the terminal equipment and can also comprise a database configured on a remote server.
Taking an application scene of page skip as an example, when a user triggers a page skip operation on an interactive interface, a first page which is currently displayed is initiated to skip to display a second page, and the second page and the first page have different content data. In response to the page skip operation, a data acquisition request may be initiated to the data source to acquire content data of the second page. Wherein the data source may comprise one or more. For example, the application program may first search for whether the cached data of the second page exists in the cache of the terminal device, if the searching in the cache fails, may continue to search for whether the client local configuration data of the second page exists in the local hard disk of the terminal device, and if the searching in the local hard disk fails, may continue to perform data communication with the remote server, thereby obtaining the content data of the second page stored on the remote server.
In one embodiment of the application, the data sources include a first data source that does not provide a connection pool and a second data source that provides a connection pool. The first data source may include DriverManagerDataSource of Spring, for example, which creates a new database connection for each connection request and destroys the connection after use. The second data source may include Apache Commons DBCP, C3P0, hikariCP, and so on, for example, which creates a number of database connections in advance and stores these connections in a pool for multiplexing by the application. The connection pool technique can significantly improve performance and reduce the overhead of connection creation and destruction.
In the Spring framework, the configuration of the data source can be implemented through an XML file or a Java configuration class. For example, when using the C3P0 connection pool, a data source type POOLED may be specified in the XML configuration file of Spring, and point to the configuration file of C3P0, where various parameters of the connection pool are defined, such as maximum connection number, minimum connection number, idle time, etc. The Spring Boot further simplifies the configuration of the data source, and provides the function of automatically configuring the data source. Without an explicit configuration data source, the Spring Boot would automatically choose to use HikariCP, tomcat a connection pool or Commons DBCP2 depending on the library under the class path. If a particular data source is required to be used, it may be specified in the application.properties file, for example, when using C3P0, spring.datasource.type=com.mchange.v2.c3p0.combopooleddatasource may be set. The configuration of the data source may include not only connection information but also configuration information concerning security, performance optimization, and high availability. For example, timeout times for connections, query caches, transaction isolation levels, etc. may be included.
The embodiment of the application adopts the first data source and the second data source to cooperate, thereby realizing configuration complementation under different application scenes. The first data source without the connection pool is suitable for the scene with less database interaction, can simplify application configuration and reduce resource occupation, and the second data source with the connection pool is introduced to remarkably improve the interaction performance of the high-frequency database, reduce the cost of connection creation and destruction by multiplexing persistent connection, optimize resource utilization rate and enhance the response speed and stability of an application program in a high concurrency environment.
And S330, when second attribute data corresponding to the data acquisition request appears in the first data channel, updating page content displayed on the interactive interface according to the second attribute data, wherein the second attribute data is used for representing attribute change information generated by the interactive interface in a response link of the interactive event.
After the application client sends the data acquisition request to the data source, the data source may return second attribute data as response data to the application client, where the second attribute data is used to represent attribute change information generated by the interactive interface in a response link of the interactive event. The second attribute data returned by the data source is written into the first data channel, so that the view controller and the view can monitor the second attribute data, and further the page content displayed on the interactive interface can be updated according to the second attribute data.
In one embodiment of the present application, the interaction event includes a page skip event from the first page to the second page, and the corresponding second attribute data may include page content to be displayed after the skip, that is, page content of the second page. The page jump event in the embodiment of the application can comprise closing the first page and opening the second page on the interactive interface, and can also comprise displaying the second page above the first page in other modes such as a floating window or a popup full-screen window.
FIG. 4 illustrates a flow chart for updating page content based on page jump events in one embodiment of the application. As shown in fig. 4, on the basis of the above embodiment, updating the page content shown on the interactive interface according to the second attribute data in step S330 may further include the following steps S331 to S333.
S331, analyzing the second attribute data to obtain a navigation link of the second page.
By analyzing the second attribute data, the navigation link of the second page carried in the navigation link can be obtained. The navigation link of the second page refers to the address of the second page in the background storage space. For example, after the data source returns the response data to the application client, the page configuration data for displaying the second page may be loaded into the memory, where the navigation link of the second page is the memory address corresponding to the stored page configuration data.
In some alternative embodiments, the navigation link of the second page may also be a uniform resource identifier URI or uniform resource locator URL pointing to the page resource, for requesting to acquire the corresponding page resource.
And S332, acquiring page configuration data of the second page according to the navigation link, wherein the page configuration data is used for representing page display content and page display effect of the second page.
The HTML, CSS, javaScript file of the second page, and possibly page configuration data, may be obtained from the navigation link. Page configuration data refers to a data structure for defining page layout, style, content and behavior, for representing page presentation content and page presentation effects of a second page, typically stored in JSON, XML or other format, that can be dynamically loaded by server-side rendering or client-side scripting.
S333, displaying a second page on the interactive interface according to the page configuration data.
And the application program client renders the page layout and style according to the page configuration data by analyzing the HTML, CSS and JavaScript of the second page, so that the page content of the second page is displayed on the interactive interface.
According to the embodiment of the application, the second attribute data is analyzed efficiently to obtain the navigation link, so that the accurate control of the second page content and the display effect is ensured, and the dynamic and flexible page rendering is realized. According to the embodiment of the application, the content is rapidly loaded and displayed through the page configuration data defined in advance, the response speed and interaction efficiency of the application program are also improved, the user interface can be dynamically adjusted according to the preset configuration, high maintainability and expandability are supported, and convenience is provided for subsequent content updating and function expansion.
In one embodiment of the application, the method for acquiring the page configuration data of the second page according to the navigation link can further comprise the steps of acquiring initial page data of the second page according to the navigation link, wherein the initial page data comprises data for initializing the second page, acquiring first page sharing data, the first page sharing data comprises data shared by the first page to the second page, writing the first page sharing data into a second data channel, the second data channel is used for transmitting data among different pages, and when a fusion instruction corresponding to the first page sharing data occurs in the second data channel, carrying out fusion processing on the initial page data and the first page sharing data according to the fusion instruction to obtain the page configuration data of the second page.
The page configuration data of the second page in the embodiment of the application comprises initial page data of the second page and page sharing data of the first page. The initial page data of the second page is page data which can be independently loaded and rendered independent of other pages, and the page sharing data of the first page refers to data which needs to be displayed on the second page depending on the page configuration of the first page.
For example, if the user does not perform any input operation related to the second page on the first page, when the user triggers to skip the second page, the page configuration may be directly completed according to the initial page data of the second page, so as to display the second page with initialized content and effects.
Conversely, if the user performs an input operation on the first page that is associated with the second page, account login is accomplished, for example, by entering user identity information. At this time, if the user triggers to jump to the second page, the first page sharing data needs to be collected and transferred to the second page, so that the page configuration is completed according to the initial page data and the first page sharing data of the second page, so as to display the second page according with the content and the effect of the user input operation. For example, the user may be presented with private data that is only viewable after the account login is completed.
The fuse instruction may include an identifier for triggering page fusion, e.g., the first page may write the first page shared data to the second data channel in the form of a data stream, at the end of which an identifier representing the fuse instruction may be written. When the second page completes receiving the second page shared data and identifies the identifier, it may be determined that the first page has completed data transfer, and then page fusion may be triggered.
In some alternative embodiments, the fusing instruction may further include a notification message for triggering page fusing, for example, the first page may write the first page sharing data into the second data channel in a data stream form, after the first page sharing data is completely written, a notification message representing the fusing instruction may be written into the second data channel, where the notification message may include summary information of the first page sharing data, for example, including a starting position and a capacity of the first page sharing data, and when the second page completes receiving the second page sharing data and receives the notification message, it may be determined whether the first page has completed data transfer according to the notification message, and may trigger page fusing after confirming that the first page sharing data is completely received.
Fig. 5 shows a schematic diagram of a framework structure for forward transferring cross-page shared data in an application scenario according to an embodiment of the present application.
As shown in fig. 5, a second data channel 503 for transferring data across pages is arranged between the first page 501 and the second page 502. When the first page 501 needs to transfer the first page shared data to the second page 502, the first page shared data may be written into the second data channel 503, and after the write operation of the first page shared data is completed, a fusion instruction is written into the second data channel 503. The second page 502 may receive the first page sharing data through the second data channel 503, and after receiving the fusion instruction, perform fusion processing on the first page sharing data and its own initial page data, to obtain updated page configuration data, so as to display the second page on the interactive interface according to the updated page configuration data.
According to the embodiment of the application, the cross-page data is intelligently acquired and processed, so that efficient and dynamic data sharing and fusion among pages are realized. The embodiment of the application firstly extracts the initial configuration data of the second page from the navigation link, then collects necessary shared data from the first page, and safely transmits the data across pages through the second data channel. After receiving the corresponding fusion instruction, the initial data and the shared data can be skillfully combined to generate complete page configuration, so that the second page can dynamically render content and interface layout according to the latest data, and the overall interactivity and data consistency of the application program are improved. In addition, the data fusion strategy also supports the modular design of the application program, so that the page updating and the function expansion are more flexible and efficient.
In one embodiment of the application, the interaction event further comprises a page return event that returns the first page from the second page.
FIG. 6 illustrates a flow diagram for updating page content based on page return events in one embodiment of the application. As shown in fig. 6, on the basis of the above embodiment, updating the page content shown on the interactive interface according to the second attribute data in step S330 may further include steps S334 to S337 as follows.
S334, collecting second page sharing data, wherein the second page sharing data comprises page data shared by the second page to the first page.
And S335, writing the second page sharing data into a second data channel.
And S336, when a fusion instruction corresponding to the second page sharing data occurs in the second data channel, carrying out fusion processing on the second page sharing data and the initial page data of the first page according to the fusion instruction to obtain page updating data of the first page.
And S337, displaying the first page on the interactive interface according to the page update data of the first page.
Fig. 7 is a schematic diagram of a framework structure for reversely transferring cross-page shared data in an application scenario according to an embodiment of the present application.
As shown in fig. 7, a second data channel 503 for transferring data across pages is arranged between the first page 501 and the second page 502. When the second page 502 needs to transfer the second page sharing data to the first page 501, the second page sharing data may be written into the second data channel 503, and after the write operation of the second page sharing data is completed, a fusion instruction is written into the second data channel 503. The first page 501 may receive the second page sharing data through the second data channel 503, and after receiving the fusion instruction, perform fusion processing on the second page sharing data and its initial page data, to obtain page update data of the first page, so that the first page is displayed on the interactive interface according to the update data.
The implementation manner and implementation effect of each method step in the embodiment of the present application may refer to the scheme of forward transfer of cross-page shared data in the above embodiment, which is not described herein again.
In one embodiment of the application, the method for displaying the second page on the interactive interface according to the page configuration data can further comprise the steps of creating a second view controller, pushing the second view controller to the top of a navigation stack, wherein the navigation stack is used for managing the page hierarchical structure displayed on the interactive interface, and displaying the second page on the interactive interface according to the second view controller and the page configuration data.
In one embodiment of the application, the interactive event further comprises a page return event for returning the first page by the second page, and the method for displaying the second page on the interactive interface according to the page configuration data after displaying the second page on the interactive interface according to the second view controller and the page configuration data can further comprise removing the second view controller from the top of the navigation stack to obtain a first view controller positioned below the second view controller, wherein the first view controller is used for managing the display process of the first page, and displaying the first page on the interactive interface according to the first view controller and the page update data of the first page.
The navigation stack is used for managing the navigation flow of the user between different view pages. In a mobile application or Web application, the navigation stack may be used to record the page path that the user has traversed from the application launch to the current location, as well as the view controller for each page.
The navigation stack maintains a hierarchical list of pages, each of which is an instance of a view controller. When the user enters a new page, the corresponding view controller is pushed onto the top of the stack, and when the user returns to the previous page, the view controller of the current page pops off the stack. The navigation stack follows the Last In First Out (LIFO) principle, i.e. the last to push view controller to the stack will be the first to pop up, which matches the navigation order of the user in the application. The user may trigger a navigation rollback operation via a back button or other interface element that causes the current view controller to pop off the stack, displaying the last view controller in the stack.
The embodiment of the application optimizes the page management by creating the special second view controller, thereby ensuring the high efficiency and order of the second page display process. By pushing the view controller into the navigation stack, the embodiment of the application skillfully utilizes the last-in first-out characteristic of the stack to maintain the page hierarchical structure, so that the page navigation is visual and easy to manage. In addition, by combining the page configuration data, the embodiment of the application can ensure that the display of the second page is consistent with the user expectation and the application design, thereby improving the consistency of user experience and the responsiveness of an interactive interface. The embodiment of the application not only enhances the navigation logic of the application, but also provides strong support for dynamic content display and interface update, and improves the smoothness and operation consistency of interface interaction.
In one embodiment of the application, an observer may be registered for the first data channel before writing the first attribute data to the first data channel, thereby listening for attribute changes on the first data channel based on the observer pattern. Specifically, the embodiment of the application can call an observer registration function executing the first data channel, wherein the observer registration function is used for registering an attribute object held by the first data channel as an observed person, the observed person is used for sending a notification to the observed person when the attribute changes, and when the observed person has the attribute changes, an observer callback function is called and executed, and the observer callback function is used for triggering the notification to the observed person and acquiring the attribute change information of the observed person according to the notification.
The embodiment of the application realizes the efficient management and response of the data state change by designing the observer mode. Firstly, the attribute object held by the first data channel is registered as an observed person by calling an observer registration function, so that once the attribute of the object changes, all registered observers can receive timely notification. This mechanism not only improves the transparency and real-time of data processing, but also enhances the response capability of the system. When the attribute of the observed person changes, an observer callback function is triggered, and is responsible for sending a notice to the observed person and acquiring the latest attribute change information so as to allow the observed person to update the state of the observed person or execute related operations according to the information. The embodiment of the application simplifies the communication flow among the components, reduces the coupling degree, makes the system more modularized and easy to maintain, and improves the flexibility and the user experience of the application.
In one embodiment of the application, the observer registration function includes a plurality of fields, such as a key path, an observation option, and a context parameter. The key value path is used for indicating an attribute object registered as an observed person, the observation option is used for indicating the observed person to send the content of a notification when the attribute changes, the context parameter is used for transmitting an identifier to the callback function of the observed person, and the identifier is used for distinguishing different attribute parameters of the observed person.
For example, the observer registration function in the embodiment of the present application may be expressed as addObserver: forKeyPath:options:context.
ForKeyPath represents a key path, which is a string of characters representing a key path (key path) of an attribute to be observed. The key path is a point-separated path for specifying attributes in an object. For example, if an attribute object person is held in the first data channel, the attribute object has an attribute parameter address, and the address further includes an attribute parameter city, where the attribute to be observed may be specified using the key path address.
Options represent observation options, some of which specify observation attributes, which are a bitmask that may include a combination of values of one or more fields as follows.
NSKeyValueObservingOptionNew providing new values of the attributes in the callback.
NSKeyValueObservingOptionOld providing the old value of the attribute in the callback.
NSKeyValueObservingOptionInitial a notification is sent immediately at the beginning of the observation, whether or not the value changes.
NSKeyValueObservingOptionPrior a notification is sent before the attribute value actually changes.
Context represents a context parameter, which is a pointer to any type, that is passed back to the observer callback method, allowing discrimination of which attribute changed when multiple attributes are observed using the same callback method. Context parameters may be used to convey an identifier or custom data in general.
The observer callback function in the embodiment of the present application may be expressed as observeValueForKeyPath: ofObject:change:context, for example. The context parameter is used to identify which attribute of the observer is triggered, and even if a plurality of attributes are observed by using the same callback method, the observer can identify which attribute is changed.
In one embodiment of the application, after updating the page content presented on the interactive interface according to the second attribute data, an observer removing function is invoked that executes the first data channel, the observer removing function being used to cancel the observed registration operation for the first data channel.
For example, the observer removal function in an embodiment of the present application may be represented as removeObserver: forKeyPath. Where observer is a pointer to the observer, i.e. the same object that was used when the observer was added before. This object needs to implement NSKeyValueObserving protocol and rewrite observeValueForKeyPath: ofObject:change:context:method to receive the observed changes. keyPath is a key path string that specifies an attribute to stop observing, which is identical to the key path used when the observer was added before.
The embodiment of the application can call the observer removing function to remove the observer when the observer (such as the view controller) is about to be destroyed or does not need to observe the change of a certain attribute, so as to avoid potential memory leakage and unnecessary observer callback.
Based on the description of the above embodiments and application scenarios, the present application utilizes the first data channel configured longitudinally and the second data channel configured transversely to realize efficient data transfer between different data processing links and different view pages, and in the processing process of the interaction event, the peer-to-peer data communication in the application program is reduced, and frequent data transfer between a large number of functional modules is not required, so that the interaction flow of the application program can be simplified to a great extent, the interaction efficiency and the data processing efficiency of the application program are improved, the response effect of the interaction interface is also enhanced, and the response speed of the interaction interface is also improved.
It should be noted that although the steps of the methods of the present application are depicted in the accompanying drawings in a particular order, this does not require or imply that the steps must be performed in that particular order, or that all illustrated steps be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step to perform, and/or one step decomposed into multiple steps to perform, etc.
The following describes an embodiment of the apparatus of the present application, which may be used to execute the page interaction method in the foregoing embodiment of the present application. Fig. 8 schematically shows a block diagram of a page interaction device according to an embodiment of the present application. As shown in fig. 8, the page interaction device 800 includes:
A writing module 810 configured to write first attribute data into a first data channel according to an interaction event triggered on an interaction interface, the interaction event including a plurality of data processing links, the first data channel being used to transfer data between different data processing links, the first attribute data being used to represent attribute change information generated by the interaction interface at an initiation link of the interaction event;
A transmitting module 820 configured to transmit a data acquisition request to a data source, the data acquisition request requesting acquisition of data responsive to the first attribute data;
the updating module 830 is configured to update, when second attribute data corresponding to the data acquisition request occurs in the first data channel, page content displayed on the interactive interface according to the second attribute data, where the second attribute data is used to represent attribute change information generated by the interactive interface in a response link of the interactive event.
In some embodiments of the present application, based on the above technical solutions, the interaction event includes a page skip event from a first page to a second page, and the update module 830 includes:
the analysis module is configured to analyze the second attribute data to obtain a navigation link of the second page;
The acquirable module is configured to acquire page configuration data of the second page according to the navigation link, wherein the page configuration data is used for representing page display content and page display effect of the second page;
And the first display module is configured to display the second page on the interactive interface according to the page configuration data.
In some embodiments of the present application, based on the above technical solution, the obtaining module further includes:
The initial acquisition module is configured to acquire initial page data of the second page according to the navigation link, wherein the initial page data comprises data for carrying out initial configuration on the second page;
a first acquisition module configured to acquire first page sharing data including data shared by the first page to the second page;
A first write module configured to write the first page shared data to a second data channel for transferring data between different pages;
And the first fusion module is configured to fuse the initial page data with the first page sharing data according to the fusion instruction when the fusion instruction corresponding to the first page sharing data occurs in the second data channel, so as to obtain page configuration data of the second page.
In some embodiments of the present application, based on the above technical solutions, the interaction event further includes a page return event for returning the first page from the second page, and the update module 830 further includes:
A second acquisition module configured to acquire second page sharing data including page data shared by the second page to the first page;
a second write module configured to write the second page sharing data to the second data channel;
The second fusion module is configured to fuse the second page sharing data with the initial page data of the first page according to the fusion instruction when a fusion instruction corresponding to the second page sharing data occurs in the second data channel, so as to obtain page updating data of the first page;
And the second display module is configured to display the first page on the interactive interface according to the page update data of the first page.
In some embodiments of the present application, based on the above technical solutions, the first display module further includes:
A view creation module configured to create a second view controller for managing a presentation process of the second page;
A view pushing module configured to push the second view controller to a top of a navigation stack for managing a page hierarchy presented on the interactive interface;
And the view display module is configured to display the second page on the interactive interface according to the second view controller and the page configuration data.
In some embodiments of the present application, based on the above technical solution, the interaction event further includes a page return event for returning the first page from the second page, and the second display module further includes:
A view removal module configured to remove the second view controller from the top of the navigation stack, resulting in a first view controller located below the second view controller, the first view controller for managing a presentation process of the first page;
and the view updating module is configured to display the first page on the interactive interface according to the first view controller and page updating data of the first page.
In some embodiments of the present application, based on the above technical solutions, the page interaction device 800 further includes:
A first function calling module configured to call an observer registration function executing the first data channel, the observer registration function being configured to register an attribute object held by the first data channel as an observed person, the observed person being configured to send a notification to the observer when an attribute changes;
And the second function calling module is configured to call and execute an observer callback function when the attribute of the observed person changes, wherein the observer callback function is used for triggering a notification to the observed person and acquiring the attribute change information of the observed person according to the notification.
In some embodiments of the present application, based on the above technical solution, the observer registration function includes the following fields:
a key value path for indicating an attribute object registered as an observed person;
an observation option for indicating the content of the notification sent by the observed person when the attribute changes;
and the context parameter is used for calling back an identifier to the observer, and the identifier is used for distinguishing different attribute parameters of the observed person.
In some embodiments of the present application, based on the above technical solutions, the page interaction device 800 further includes:
And a third function calling module configured to call an observer removing function for executing the first data channel, the observer removing function being used for canceling an observed registration operation for the first data channel.
Specific details of the page interaction device provided in each embodiment of the present application have been described in the corresponding method embodiments, and are not described herein.
Fig. 9 schematically shows a block diagram of a computer system of an electronic device for implementing an embodiment of the application.
It should be noted that, the computer system 900 of the electronic device shown in fig. 9 is only an example, and should not impose any limitation on the functions and the application scope of the embodiments of the present application.
As shown in fig. 9, the computer system 900 includes a central processing unit 901 (Central Processing Unit, CPU) that can perform various appropriate actions and processes according to a program stored in a Read-Only Memory 902 (ROM) or a program loaded from a storage portion 908 into a random access Memory 903 (Random Access Memory, RAM). In the random access memory 903, various programs and data required for system operation are also stored. The cpu 901, the rom 902, and the ram 903 are connected to each other via a bus 904. An Input/Output interface 905 (i.e., an I/O interface) is also connected to bus 904.
Connected to the input/output interface 905 are an input section 906 including a keyboard, a mouse, and the like, an output section 907 including a Cathode Ray Tube (CRT), a Liquid crystal display (Liquid CRYSTAL DISPLAY, LCD), and the like, and a speaker, and the like, a storage section 908 including a hard disk, and the like, and a communication section 909 including a network interface card such as a local area network card, a modem, and the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the input/output interface 905 as needed. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on the drive 910 so that a computer program read out therefrom is installed into the storage section 908 as needed.
In particular, the processes described in the various method flowcharts may be implemented as computer software programs according to embodiments of the application. For example, embodiments of the present application include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from the network via the communication portion 909 and/or installed from the removable medium 911. When executed by the central processor 901, performs various functions defined in the system of the present application.
It should be noted that, the computer readable medium shown in the embodiments of the present application may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of a computer-readable storage medium may include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-Only Memory (ROM), an erasable programmable read-Only Memory (Erasable Programmable Read Only Memory, EPROM), a flash Memory, an optical fiber, a portable compact disc read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present application, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
It should be noted that although in the above detailed description several modules or units of a device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functions of two or more modules or units described above may be embodied in one module or unit in accordance with embodiments of the application. Conversely, the features and functions of one module or unit described above may be further divided into a plurality of modules or units to be embodied.
From the above description of embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or may be implemented in software in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present application may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.) or on a network, and includes several instructions to cause a computing device (may be a personal computer, a server, a touch terminal, or a network device, etc.) to perform the method according to the embodiments of the present application.
Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains.
It is to be understood that the application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.