CN112698824B - View element state management method, device, electronic equipment and storage medium - Google Patents
View element state management method, device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN112698824B CN112698824B CN202110013533.3A CN202110013533A CN112698824B CN 112698824 B CN112698824 B CN 112698824B CN 202110013533 A CN202110013533 A CN 202110013533A CN 112698824 B CN112698824 B CN 112698824B
- Authority
- CN
- China
- Prior art keywords
- state
- target
- management
- behavior
- view element
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000007726 management method Methods 0.000 title claims description 367
- 230000006399 behavior Effects 0.000 claims abstract description 258
- 238000012545 processing Methods 0.000 claims abstract description 70
- 238000000034 method Methods 0.000 claims abstract description 69
- 230000008569 process Effects 0.000 claims abstract description 41
- 230000006870 function Effects 0.000 claims description 27
- 238000004590 computer program Methods 0.000 claims description 17
- 230000008859 change Effects 0.000 claims description 14
- 230000000694 effects Effects 0.000 abstract description 10
- 230000005540 biological transmission Effects 0.000 abstract description 7
- 238000012546 transfer Methods 0.000 abstract description 6
- 230000009471 action Effects 0.000 description 46
- 238000010586 diagram Methods 0.000 description 18
- 239000003638 chemical reducing agent Substances 0.000 description 16
- DBGIVFWFUFKIQN-UHFFFAOYSA-N (+-)-Fenfluramine Chemical compound CCNC(C)CC1=CC=CC(C(F)(F)F)=C1 DBGIVFWFUFKIQN-UHFFFAOYSA-N 0.000 description 13
- 238000013461 design Methods 0.000 description 10
- 230000003287 optical effect Effects 0.000 description 5
- 238000004891 communication Methods 0.000 description 4
- 238000011161 development Methods 0.000 description 3
- 230000003993 interaction Effects 0.000 description 3
- 230000002452 interceptive effect Effects 0.000 description 3
- 230000001960 triggered effect Effects 0.000 description 3
- 238000009825 accumulation Methods 0.000 description 2
- 239000008186 active pharmaceutical agent Substances 0.000 description 2
- 238000013459 approach Methods 0.000 description 2
- 238000013507 mapping Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 239000013307 optical fiber Substances 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 101710154918 Trigger factor Proteins 0.000 description 1
- 230000003542 behavioural effect Effects 0.000 description 1
- 230000008901 benefit Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 239000013078 crystal Substances 0.000 description 1
- 230000004069 differentiation Effects 0.000 description 1
- 238000005538 encapsulation Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000004907 flux Effects 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000002360 preparation method Methods 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000004153 renaturation Methods 0.000 description 1
- 238000009877 rendering Methods 0.000 description 1
- 230000003252 repetitive effect Effects 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 230000002441 reversible effect Effects 0.000 description 1
Landscapes
- Stored Programmes (AREA)
Abstract
The method comprises the steps of firstly obtaining target state behaviors of a target view element, then determining a target management tool according to the target state behaviors in a state management library, and then calling the target management tool to process the target state behaviors so as to determine a new state of the target view element. The state management library of the embodiment of the disclosure combines the state behaviors and the logic processors for processing the state behaviors to form the management tool, and when the state behaviors are processed, the management tool is directly instantiated, so that the state update can be completed without the state behavior transmission through a plurality of transfer modules like the prior art, and the technical problems of excessive template codes, weak type support and complex interface definition in the state management framework in the prior art are solved. The technical effects of simplifying the state management framework, greatly reducing template codes and being applicable to TYPESCRIPT type systems are achieved.
Description
Technical Field
The embodiment of the disclosure relates to the technical field of computer and network communication, in particular to a view element state management method, a device, electronic equipment and a storage medium.
Background
In recent years, with the rise of single page applications, javaScript needs to manage more states than at any time, or so to speak, data, including: server responses, caching data, locally generated data that has not been persisted to the server, and UI state, such as active routes, selected tags, whether to display loading actions or pagers, etc., are challenges not encountered by web development twenty years ago. As the single page application of the front-end rendered page increases in duty, this represents that the complexity of the front-end work also increases in a straight line, and the information presented on the front-end page increases in complexity. This makes management of the state more important.
Currently, a large number of front-end projects are being developed using or turning to frameworks such as vue.js and exact.js. Among them, flux, redux, vuex, mobx and so on are used in many third party frameworks for front-end state management, and the application in reduce is most widely used. There are two modes of use of reduce: the first is the mere use of a pure reduce library, which has the obvious disadvantage of requiring the introduction of a state library store where data is changed and listened to, and the manual association with components, thus creating a second way; the second is to use the reduce + react-reduce approach, which does not manually handle the global state versus react relationship, but the code is compact, but in this approach, two modules action creator and the reducer are needed. action creator write a large number of repeated codes, reducer and frequently used SWITCH CASE statements; the redundant character string types of the Redux framework are used for carrying out parameter transmission, so that the mode is difficult to adapt to TYPESCRIPT type systems, strict constraint of codes is difficult to realize, and error codes are easy to write; furthermore, the Redux splits a plurality of modules, so that a data modification needs to be carried out by modifying a plurality of modules associated with the data modification, and great inconvenience is brought to state management development work.
Namely, the state management framework in the prior art has the technical problems of too many template codes, weak type support and complex interface definition.
Disclosure of Invention
The embodiment of the disclosure provides a view element state management method, a device, electronic equipment and a storage medium, which are used for solving the technical problems of excessive template codes, weak type support and complex interface definition in a state management framework in the prior art.
In a first aspect, an embodiment of the present disclosure provides a view element state management method, including:
acquiring a target state behavior of a target view element, wherein the target state behavior is used for determining a change type of a state, and the state is a logic state of the target view element;
In a state management library, determining a target management tool according to target state behaviors, wherein the state management library comprises a plurality of management tools, and the management tools comprise logic processors which are used for processing logic relations between states and state behaviors of view elements in the management tools;
The target management tool is invoked to process the target state behavior to determine the new state of the target view element.
In a second aspect, an embodiment of the present disclosure provides a view element state management apparatus, including:
The acquisition module is used for acquiring the target state behavior of the target view element, wherein the target state behavior is used for determining the change type of the state, and the state is the logic state of the target view element;
The state management library module is used for determining a target management tool according to target state behaviors, the state management library module comprises a plurality of management tools, the management tools comprise logic processors, and the logic processors are used for processing logic relations between states and state behaviors of view elements in the management tools;
and the processing module is used for calling the target management tool to process the target state behavior so as to determine the new state of the target view element.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
At least one processor and memory;
the memory stores computer-executable instructions;
The at least one processor executes the computer-executable instructions stored by the memory, causing the at least one processor to perform the view element state management method as described above in the first aspect and the various possible designs of the first aspect.
In a fourth aspect, embodiments of the present disclosure provide a computer readable storage medium having stored therein computer executable instructions that when executed by a processor implement the view element state management method according to the first aspect and the various possible designs of the first aspect.
In a fifth aspect, embodiments of the present disclosure provide a computer program product comprising a computer program which, when executed by a processor, implements the view element state management method according to the first aspect and the various possible designs of the first aspect.
The method comprises the steps of firstly obtaining target state behaviors of a target view element, then determining a target management tool according to the target state behaviors in a state management library, and then calling the target management tool to process the target state behaviors so as to determine a new state of the target view element. The state management library of the embodiment of the disclosure combines the state behaviors and the logic processors for processing the state behaviors to form the management tool, and when the state behaviors are processed, the management tool is directly instantiated, so that the state update can be completed without the state behavior transmission through a plurality of transfer modules like the prior art, and the technical problems of excessive template codes, weak type support and complex interface definition in the state management framework in the prior art are solved. The technical effects of simplifying the state management framework, greatly reducing template codes and being applicable to TYPESCRIPT type systems are achieved.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the solutions in the prior art, a brief description will be given below of the drawings that are needed in the embodiments or the description of the prior art, it being obvious that the drawings in the following description are some embodiments of the present disclosure, and that other drawings may be obtained from these drawings without inventive effort to a person of ordinary skill in the art.
FIG. 1 is a schematic diagram of a state management logic provided in an embodiment of the present disclosure;
FIG. 2 is a logic diagram of a Redux framework management state provided by an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of the state library of FIG. 2 according to an embodiment of the present disclosure;
fig. 4 is a schematic diagram of a structure and an application scenario of a state management library according to an embodiment of the present disclosure;
FIG. 5 is a flowchart illustrating a method for managing a state of a view element according to an embodiment of the present disclosure;
Fig. 6 is a schematic diagram of an application scenario of a view element state management method according to an embodiment of the present application;
fig. 7 is a second flowchart of a view element state management method according to an embodiment of the present disclosure;
Fig. 8 is a flowchart illustrating a view element state management method according to an embodiment of the present disclosure;
FIG. 9 is a diagram illustrating the logical relationships of a state management library, a context provider, and context components provided by an embodiment of the present application;
FIG. 10 is a block diagram of a view element state management device provided by an embodiment of the present disclosure;
Fig. 11 is a schematic hardware structure of an electronic device according to an embodiment of the disclosure.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are some embodiments of the present disclosure, but not all embodiments. Based on the embodiments in this disclosure, all other embodiments, including but not limited to combinations of embodiments, that would be obtained by one of ordinary skill in the art without inventive effort are within the scope of this disclosure.
The terms "first," "second," "third," "fourth" and the like in the description and in the claims and in the above-described figures, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the disclosure described herein may be capable of operation in sequences other than those illustrated or described herein, for example. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The terminology involved in the present application is explained below for the sake of easy understanding.
Status: the states in this disclosure are the data sources used to control the effects of the presentation of the view elements.
State management: the data sources for controlling the display effect of the view elements are independently extracted, and are managed uniformly independently of the logic flow of the processing method, so that the logic of state change can be predicted better, and only the logic connection is highlighted, thus the logic is realized more orderly, and the state change is easier to control.
The reason why the state management is to be performed is described here. Because there is typically some shared state between view elements, we will typically promote this part of the state into global variables, the shared state is managed uniformly by the global component, and the view element update needs to be notified when the state changes. However, as the states become more and more complex, a state management tool is urgently needed to help comb the logic of shared states, and state management tools have also grown.
The basic logic of the framework mode of state management proceeds as follows:
1. storing state states of the view elements in an external state library store;
2. the state is used for controlling the display effect or the display effect of the view element;
3. the view element changes state by triggering logic behavior or state behavior actions, and updates the view element to display the new state.
The initial inventive concept of the present disclosure is formed according to the above mode, and a corresponding flow of state management is shown in fig. 1.
Referring to fig. 1, fig. 1 is a schematic diagram of a state management logic according to an embodiment of the present disclosure. As shown in fig. 1, the state library Store10 receives a state behavior notification of the view element 11, where the view element 11 in fig. 1 includes at least two view elements, that is, the view element 111 and the view element 112, which may trigger the state behavior notification respectively or simultaneously. After receiving the notification of the status behavior by the view element 11, the status library Store10 sends the shared status 101 of the view element 111 and the view element 112 to the corresponding view element 111 or the view element 112, respectively, or sends the shared status to both the view element 111 and the view element 112.
In this process, the most complex problem is how to perform state management.
For convenience in explaining the inventive concept of the embodiments of the present disclosure, management logic of a reduce framework for state management in the related art will be described.
In the Redux framework, there are three core modules, namely a state library Store, behavior actions, behavior processing module Reducer.
(1) A state library Store:
the State for storing each view element in the application, and the dispatch method for triggering the update of the State, etc., there is only one State library Store in the whole application.
Several interface tool APIs are provided in the State library Store that manage State:
■ store.getstate (): acquiring a current State;
■ store, dispatch (Action): sending a behavior Action to a behavior processing module Reducer for processing;
■ store, subscore (listener): a snoop function listener is set that listens for State changes (if the view element update function is entered as snoop function listener, then the view auto-rendering may be triggered).
(2) Action:
The Action is a parameter generated by the Action Creator and received by the Action processing module Reducer, which was originally triggered by the view element.
The Action contains the following information:
● A type field of a string type to indicate a behavior Action to be performed;
● Other data information that needs to be passed to the application, data form or type user can be customized.
(3) Behavior processing module Reducer:
is a function that computes a new State newState based on the behavior Action and the State. I.e. deriving a new state newState by applying the current state previousState and the behavioural Action:
Can be expressed as: (previousState, action) = > newState.
Referring to fig. 2, fig. 2 is a logic schematic diagram of a reduce framework management state provided in an embodiment of the present disclosure. As shown in FIG. 2, after a user performs an interactive operation on a view element on a front-end page, a tracker trigger captures a behavior Action, the tracker trigger triggers a behavior encapsulation Creator Action Creator to generate a character string corresponding to the behavior Action, then a store.dispatch (Action) in a state Store transmits the behavior Action to the state Store through the character string, the state Store invokes a behavior processing module Reducer and generates a new state newState, and then the state Store updates the state of the view element and displays the new state.
It should be noted that there is typically a connection processor in the state library Store for handling connection relationships for receiving Action actions and delivering new/old states. The behavior processing module Reducer may generally include a plurality of modules corresponding to different logic behaviors, where when the logic behaviors have a progressive inclusion relationship or have a logic sequence relationship with each other, as shown in fig. 2, the relationship between the respective behavior processing modules Reducer is shown in fig. 2, and the root behavior processing module represents the logic behavior with the largest coverage, and the corresponding logic behaviors may be further subdivided into two branches, such as the behavior processing module 1 to the behavior processing module 2, and the behavior processing module 3 to the behavior processing module 4, where the two branches represent two parallel logics. If the root logic processing module is a four-rule operation module, the behavior processing module 1 represents accumulation behavior, the behavior processing module 3 represents accumulation behavior, the behavior processing module 2 represents addition behavior of two variables, and the behavior processing module 4 represents multiplication behavior of two variables.
As can be seen from FIG. 2, in the state management of the existing Redux framework, the Action needs to be passed to the state library Store by the Action package Creator Action Creator package a string representing the Action Type, and other data related to the Action. The two steps of operation make the application developer need to prepare a large amount of repetitive template codes to enable the Redux framework to be effective, and since the Action package Creator Action Creator attaches the Action Type character String to the Action, the character String causes a Type contradiction on the TYPESCRIPT Type system with the added variable Type as an important core, because the Action itself can be regarded as a group Array Type, but the Action is given to the character String Type after utilizing the Redux framework, the Type conflict is caused, and the Redux framework has an unsupported problem for the TYPESCRIPT Type system.
How to improve the reduce framework, so that when managing a large number of states, a large number of renaturation template codes are caused, and a new state management framework can support TYPESCRIPT systems with variable addition type limitation as a core, is needed to solve the technical problem, namely, the innovation starting point of the present disclosure.
The inventors of the present disclosure, after intensive studies, found that a difficulty in solving the above-described problems is how the Action package Creator Action Creator and Store. Achieving the state Store update state directly triggered by state behavior as shown in fig. 1 is the biggest technical hurdle faced by embodiments of the present disclosure.
After intensive research, the inventor of the present disclosure finds that the core module actually playing a role in acquiring a new State in the reduce framework is "behavior processing module Reducer", and the State library Store only plays a role in storing the State, but this simple storage manner cannot meet the requirement of efficient utilization. In order to more easily understand the problems of the existing Redux framework, a brief description is provided below in connection with FIG. 3.
Referring to fig. 3, fig. 3 is a schematic structural diagram of the state library in fig. 2 according to an embodiment of the present disclosure. As shown in fig. 3, the state library 300 in the reduce framework simply stores the states corresponding to the various view elements, and the first state set 301, the second state set 302, the third state set 303, the fourth state set 304, the fifth state set 305, the sixth state set 306, and the seventh state set 307 shown in fig. 3 correspond to different states of different view elements respectively. If the State is considered as a part, the behavior processing module Reducer is a machine for processing the part, the old part is processed by the machine to obtain a new part, and the behavior Action is a switch button of the machine. This is the relationship among the state library Store, behavior processing module Reducer, and behavior Action in the existing Redux framework.
For the relationship between the above three, the inventor of the present disclosure has found that the existing reduce framework needs many template codes to connect, and it is necessary to ensure that the behavior processing module Reducer used by the State with changed behavior is registered, otherwise, logic call errors will be caused, so that the reduce framework cannot complete State update. That is, the machine corresponding to the switch button is an existing machine to machine the parts, and if the machine corresponding to the switch button is not installed and ready, the parts cannot be machined, thereby causing errors.
The inventive concept of the present disclosure was thus obtained: embodiments of the present disclosure creatively break through this responsive behavior Action or logic structure of the Redux framework of the prior art. The behavior processing module Reducer, the behavior Action and the State are combined together to form a management tool. When the Action is captured, a management tool matched with the Action can be correspondingly found, and the management tool is instantiated to generate an instance corresponding to the management tool, wherein the instance exists along with the view element and is specially used for managing the state generated by the preset Action corresponding to the view element. The original state library is correspondingly changed into a state management library for storing each state management tool. The state management library can be set as a type system, namely, the related variables prescribe the data types, the accurate calling of each data is ensured through the type limitation of the type system, the condition that a behavior processing module Reducer is called without being registered in the existing reduce framework does not exist, a large number of target codes are not needed to construct an Action Creator and a store. Meanwhile, variable type limitation is added into a state management library and a state management tool so as to meet the support requirement of TYPESCRIPT type systems, and the technical problem that the type support is weak in the existing state management framework is solved.
For ease of understanding, the state management library of embodiments of the present disclosure is described below in conjunction with FIG. 4.
Referring to fig. 4, fig. 4 is a schematic diagram of a structure and an application scenario of a state management library according to an embodiment of the present disclosure. As shown in fig. 4, the state management library 400 includes a plurality of management tools, such as a first management tool 401, a second management tool 402, and a third management tool 403. After the state behavior 411 is captured by the tracker trigger, the interface tool API (Application Programming Interface, application program interface) of the state management library finds the corresponding management tool, i.e., the first management tool 401, and converts it into the first instance 4011. The state behavior 411 is then used to activate the first instance 4011, and after processing by the first instance 4011, the output gets a new state 412.
Specific steps of the view element state management method provided in the embodiments of the present disclosure are described in detail below.
Referring to fig. 5, fig. 5 is a flowchart illustrating a view element state management method according to an embodiment of the disclosure. The method of the embodiment is applied to the terminal equipment and/or the server of the user side, and the view element state management method comprises the following steps:
s501: the target state behavior of the target view element is acquired.
In this step, the target state behavior is used to determine the type of change of state, which is the logical state of the target view element.
Specifically, after the user operates the target view element, that is, after the user performs interactive operation with the target view element, the state of each view element in the application can be detected in real time by setting a patrol thread or a state tracker trigger in the application. The user interaction with the target view element thus constitutes a trigger for the change of state of the target view element, i.e. the target state behavior.
Referring to fig. 6, fig. 6 is a schematic view of an application scenario of a view element state management method according to an embodiment of the present application. As shown in FIG. 6, when the user clicks the "Add 1 button 601" or "Add 2 button 602" on the application interface, the patrol thread or state tracker trigger captures this interaction, i.e., the target state behavior. In fig. 6, the target view element is a digital display element 603.
S502: in the state management library, a target management tool is determined according to the target state behavior.
In this step, the state management library includes a plurality of management tools, and the management tools include a logic processor, where the logic processor is configured to process a logic relationship between a state and a state behavior of a view element in the management tools.
Specifically, a target management tool corresponding to a target state behavior may be retrieved in the state management library through an interface component of the state management library, such as a hook Hooks component. It should be noted that, the number of target management tools required for different target state behaviors is different, for example, one weighted average calculation button may use an addition management tool and a multiplication management tool, respectively, and may also directly use a weighted average management tool. Thus, for a target state behavior, a target management tool can be found in the state management library.
For example, as shown in fig. 6, the add 1 button 601 corresponds to an "add 1" management tool, that is, a target management tool, which handles the logical behavior of "add", and the logical behavior of "add" needs to have "added" and "add", where "added" corresponds to the old state PreviousState of the digital display element 603, and "add" is a state variable in which a variable type is defined in a logical processor in the "add 1" management tool, where the state variable is 1, and the variable type is digital. It should be noted that, the difference between the logic processor in the "add 1" management tool and the behavior processing module Reducer in the prior art includes defining the variable type of the state variable, so that if the developer invokes the wrong logic processor or the target management tool, the compiler or the compilation environment tool will automatically prompt the logic error, and it is not necessary to construct an Action Creator and a store. The method saves a large number of repeated template code works, improves the efficiency of application development, simplifies the volume of the application code, and improves the processing compiling efficiency.
It should be noted that in one possible design, the old state PreviousState of the target view element is included in all management tools that use the old state, and when this old state update changes to the new state, all management tools will also update in the same step.
It should also be noted that in another possible design, the target management tool includes parameters defining the type, such as the old state PreviousState, in addition to the logical processor, which enables the target management tool to support TYPESCRIPT type systems well.
I.e. the parameters in the management tool and the logical processor define parameter types, the parameter types comprising: at least one of a numerical value, an array, text, and a function;
The parameter type is used to ensure that no logical errors occur when the target state behavior is handled by the call to the target management tool.
S503: the target management tool is invoked to process the target state behavior to determine the new state of the target view element.
In this step, since the target management tool already includes a logic processor, the basic design of fig. 1 is implemented to directly process the corresponding logic relationship according to the state behavior to determine the new state. The above problems in the Redux framework are truly avoided.
According to the view element state management method provided by the embodiment of the disclosure, the target state behavior of the target view element is firstly obtained, then a target management tool is determined in a state management library according to the target state behavior, and then the target management tool is called to process the target state behavior so as to determine the new state of the target view element. The state management library of the embodiment of the disclosure combines the state behaviors and the logic processors for processing the state behaviors to form the management tool, and when the state behaviors are processed, the management tool is directly instantiated, so that the state update can be completed without the state behavior transmission through a plurality of transfer modules like the prior art, and the technical problems of excessive template codes, weak type support and complex interface definition in the state management framework in the prior art are solved. The technical effects of simplifying the state management framework, greatly reducing template codes and being applicable to TYPESCRIPT type systems are achieved.
Referring to fig. 7, fig. 7 is a second flowchart of a view element state management method according to an embodiment of the disclosure. The method of the embodiment is applied to the terminal equipment and/or the server of the user side, and the view element state management method comprises the following steps:
S701: the target state behavior of the target view element is acquired.
In this step, the target state behavior is used to determine the type of change of state, which is the logical state of the target view element.
Specifically, after the user operates the target view element, that is, after the user performs interactive operation with the target view element, the state of each view element in the application can be detected in real time by setting a patrol thread or a state tracker trigger in the application. The user interaction with the target view element thus constitutes a trigger for the change of state of the target view element, i.e. the target state behavior.
S702: according to the target state behavior, a target management tool is determined in a state management library through a target pointer of the hook interface component.
In this step, the state management library includes: a logical processor set, a state behavior set, an initial state set, and a management tool set; the management tool set comprises a plurality of management tools, and the management tools comprise logic processors which are used for processing logic relations between states and state behaviors of view elements in the management tools.
It should be noted that the set of logical processors includes logical processors in each management tool, the set of state behaviors includes state behaviors involved in each management tool, and the set of initial states includes initial states of each state behavior.
In this embodiment, the set of logical processors, the set of state behaviors, and the set of initial states are used to provide initial states of the logical processors, the state behaviors, and the respective states involved in a management tool when the management tool is newly created. After a management tool is first established, it is added to the management tool set, and a corresponding pointer is established for the management tool, so that the management tool can be quickly found when the management tool is called, and the search is not traversed one by one.
It should be further noted that, the hook interface component, such as a hook class function object, is an API interface component corresponding to the state management library, and each management tool in the management tool set has its corresponding pointer, where the pointers are stored in the hook interface component.
S703: the target state behavior is processed by calling a target management tool according to the target pointer to determine a new state of the target view element.
In this step, after the hook interface component finds the corresponding target management tool through the target pointer, the hook interface component transmits the state behavior to the target management tool for logic processing, so as to obtain the new state of the target view element.
According to the view element state management method provided by the embodiment of the disclosure, firstly, the target state behavior of the target view element is obtained, then, a target management tool is determined in a state management library through the target pointer of the hook interface assembly according to the target state behavior, and then, the target management tool is called according to the target pointer to process the target state behavior so as to determine the new state of the target view element. On the basis of the embodiment shown in fig. 5, the target management tool is quickly located by using a pointer, and a logical processor set, a state behavior set, an initial state set and a management tool set are added in the state management library so as to update or newly establish the management tool or initialize the management tool. The state management library of the embodiment of the disclosure combines the state behaviors and the logic processors for processing the state behaviors to form the management tool, and when the state behaviors are processed, the management tool is directly instantiated, so that the state update can be completed without the state behavior transmission through a plurality of transfer modules like the prior art, and the technical problems of excessive template codes, weak type support and complex interface definition in the state management framework in the prior art are solved. The technical effects of simplifying the state management framework, greatly reducing template codes and being applicable to TYPESCRIPT type systems are achieved.
Referring to fig. 8, fig. 8 is a flowchart illustrating a view element state management method according to an embodiment of the disclosure. The method of the embodiment is applied to the terminal equipment and/or the server of the user side, and the view element state management method comprises the following steps:
S801: the target state behavior of the target view element is obtained through the hook interface component.
In this step, the target state behavior includes: the current state of the target behavior object and the target logic behavior. The logic behavior is a trigger factor that triggers an inherent logic relationship of a state change, including: operational logic behavior, decision logic behavior, selection logic behavior, etc. Such as: the addition, subtraction, multiplication, division, integration and differentiation belong to the operation logic behavior, and the Boolean class belongs to the judgment logic behavior.
S802: and determining a target pointer corresponding to the target management tool according to the target logic behavior by utilizing the hook interface component.
In this step, the target pointer is included in the hook interface component, and there is a mapping relationship between the target logic behavior and the target pointer, so that the corresponding target pointer can be searched from the mapping table.
It should be noted that, when the new state corresponding to the target state behavior is a state shared by multiple view elements, a context component is required to obtain a target pointer corresponding to a shared target management tool.
Specifically, the target logic behavior must have a certain context support when determining the target pointer, that is, must make logic settings of various transfer parameters and definition limits of parameter types, and the specific steps include:
S8021: a context provider that obtains the target pointer based on the logical behavior.
In this step, a plurality of context providers, such as contextProvider in Java, are attached to the state management library or to the hook interface component of the state management library to provide corresponding interface APIs for interfacing the logical behavior with the target pointers.
S8022: the target pointer is determined from the context provider.
In this step, the corresponding target pointer is pulled directly from the hook interface component by the context provider. Specifically, the method comprises the following steps:
obtaining a context component of a context provider package;
The target pointer is determined from the context component.
It should be noted that the context provider is configured to provide a connection interface for the state management library to a context component (e.g., context in Java) that is configured to provide logical call context support for a call target management tool.
To facilitate understanding of the implementation principle of step S802, the following is visually illustrated in conjunction with fig. 9.
Referring to fig. 9, fig. 9 is a schematic diagram of a logical relationship among a state management library, a context provider, and a context component provided by an embodiment of the present application. As shown in fig. 9, the state management library 91 includes a plurality of management tools, namely, a management tool 911, a management tool 912 and a management tool 913, each of which corresponds to a specific transmission pipeline in the context provider 92, so that the context provider 921, the context provider 922 and the context provider 923 can be regarded as a gateway from which the management tool 911, the management tool 912 and the management tool 913 leave the state management library when they are called or as a corresponding library manager, and can leave the state library only through the corresponding gateway or the library manager to be called, and the context component corresponds to a transport channel or a transport carrier after leaving the library, and the management tool 911 can be transported only in the context component 931, and the management tool 912 can be transported only in the context component 932, and likewise, the management tool 912 can be transported only in the context component 933 and finally reach the called place. This is a specific procedure in the state library where the management tool is called, and this procedure ensures that the management tool is strictly limited to the logic of the call, and that the context provider and/or the context component trigger a compilation alarm when a call logic error occurs, thus ensuring that no logic error occurs when the state behavior directly calls the management tool, and avoiding that the Creator Action Creator and the template code corresponding to the store. Dispatch method tool need to be encapsulated with a large number of repeated behaviors like the reduce framework to avoid the logic error.
S803: the target management tool is invoked to process target state behavior according to the target context component to determine a new state of the target view element.
In this step, the target context component passes intermediate parameters such as global variables for the target management tool to handle state changes corresponding to the target state behavior, so that the target management tool eventually generates a new state.
S804: the new state is configured for the target view element update by the state assigner.
After the new state is generated, the state management library is equivalent to the original Store, and the new state is updated for the target view element through a corresponding state provider, namely a function tool for resetting or updating the view element, such as a render method tool, so that the target view element displays the new state.
Optionally, each management tool associated with the state of the target view element also updates this state synchronously, or replaces the initial state in the state management library with a new state.
In one possible design, in order for the state assigner to meet the preparation requirement for configuring the new state, before step S808, the method further includes:
a function selector is obtained for configuring individual parameters in the state assigner and/or the invoked object configuration model.
The state assigner is configured according to the function selector such that the state assigner meets new state configuration requirements of the target view element.
According to the view element state management method provided by the embodiment of the disclosure, firstly, the target state behavior of the target view element is obtained, then, a target management tool is determined in a state management library through the target pointer of the hook interface assembly according to the target state behavior, and then, the target management tool is called according to the target pointer to process the target state behavior so as to determine the new state of the target view element. Based on the embodiment shown in fig. 5, pointers are utilized to quickly locate the target management tool and add a context provider and context components to the state management library to provide a more compact multiplexed interface tool for the invocation of the management tool. The state management library of the embodiment of the disclosure combines the state behaviors and the logic processors for processing the state behaviors to form the management tool, and when the state behaviors are processed, the management tool is directly instantiated, so that the state update can be completed without the state behavior transmission through a plurality of transfer modules like the prior art, and the technical problems of excessive template codes, weak type support and complex interface definition in the state management framework in the prior art are solved. The technical effects of simplifying the state management framework, greatly reducing template codes and being applicable to TYPESCRIPT type systems are achieved.
Corresponding to the media pushing method of the above embodiment, fig. 10 is a block diagram of a view element state management device provided in an embodiment of the present disclosure. For ease of illustration, only portions relevant to embodiments of the present disclosure are shown. Referring to fig. 10, the apparatus includes:
an obtaining module 1001, configured to obtain a target state behavior of a target view element, where the target state behavior is used to determine a change type of a state, and the state is a logic state of the target view element;
a state management library module 1002, configured to determine a target management tool according to the target state behavior, where the state management library module includes a plurality of management tools, and the management tools include a logic processor, and the logic processor is configured to process a logic relationship between a state and a state behavior of a view element in the management tools;
a processing module 1003, configured to invoke the target management tool to process the target state behavior to determine a new state of the target view element.
In one embodiment of the disclosure, the management tool and the parameters in the logical processor define parameter types including: at least one of a numerical value, an array, text, and a function;
the parameter type is used for being correctly called when the target management tool is called to process the target state behavior.
In one embodiment of the present disclosure, the state management library module 1002 further includes: a logical processor set, a state behavior set, an initial state set, and a management tool set;
the set of logical processors includes the logical processors in each of the management tools;
the set of state behaviors includes the state behaviors in each of the management tools;
the initial state set comprises initial states of the state behaviors;
The set of management tools includes all of the management tools.
In one embodiment of the present disclosure, the state management library module 1002 is configured to determine a target management tool according to the target state behavior, including:
The state management library module 1002 is configured to determine, according to the target state behavior, at least one target management tool in the state management library through a target pointer of a hook interface component;
the hook interface assembly comprises pointers corresponding to the management tools.
In one embodiment of the disclosure, the processing module 1003, configured to call the target management tool to process the target state behavior, includes:
The processing module 1003 is configured to call the target management tool to process the target state behavior according to the target pointer.
In one embodiment of the present disclosure, the target state behavior includes: the obtaining module 1001 is configured to obtain the current state of the target behavior object and the target logic behavior, where the obtaining the target state behavior of the target view element includes:
the obtaining module 1001 is configured to obtain the current state and the target logic behavior through a hook interface component;
correspondingly, the state management library module 1002 is configured to determine a target management tool according to the target state behavior, and includes:
The state management library module 1002 is configured to determine, by using the hook interface component, a target pointer corresponding to the target management tool according to the target logic behavior, where the target pointer is included in the hook interface component;
the state management library module 1002 is further configured to determine the target management tool according to the target pointer and the state management library.
In one embodiment of the present disclosure, when the new state corresponding to the target state behavior is a state shared by multiple view elements, the state management library module 1002 is configured to determine, according to the target logic behavior, a target pointer corresponding to the target management tool, including:
the state management library module 1002 is configured to obtain a context provider of the target pointer according to the target logic behavior;
The state management library module 1002 is further configured to determine the target pointer according to the context provider.
In one embodiment of the present disclosure, the context provider is configured to provide a connection interface to the state management library and context component, and the processing module 1003 is configured to determine the target pointer according to the context provider, including:
The processing module 1003 is configured to obtain the context component of the context provider package;
The processing module 1003 is further configured to determine the target pointer according to the context component.
In one embodiment of the disclosure, the processing module 1003, configured to invoke the target management tool to process the target state behavior to determine a new state of the target view element, includes:
the processing module 1003 is configured to invoke the target management tool to process the target state behavior according to the target context component to determine a new state of the target view element.
In one embodiment of the present disclosure, the view element state management apparatus 1000 further includes:
The processing module 1003 is further configured to update, by a state assigner, the new state to the target view element.
In one embodiment of the present disclosure, before the processing module 1003 is further configured to update the new state for the target view element by using a state assigner, the method further includes:
The obtaining module 1001 is further configured to obtain a function selector for configuring each parameter in the state assigner and/or the invoked target configuration model;
The processing module 1003 is further configured to configure the state assigner according to the function selector, so that the state assigner meets a new state configuration requirement of the target view element.
The apparatus 1000 provided in this embodiment may be used to execute steps related to a user side in the technical solution of the foregoing method embodiment, and its implementation principle and technical effects are similar, which is not described herein again.
Referring to fig. 11, there is shown a schematic structural diagram of an electronic device 1100 suitable for use in implementing embodiments of the present disclosure, the electronic device 1100 may be a terminal device or a server. The terminal device may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a Personal Digital Assistant (PDA) or the like, a tablet computer (Portable Android Device) or the like, a Portable Multimedia Player (PMP) or the like, a car-mounted terminal (e.g., car navigation terminal) or the like, and a fixed terminal such as a digital TV or a desktop computer or the like. The electronic device shown in fig. 11 is merely an example, and should not impose any limitations on the functionality and scope of use of embodiments of the present disclosure.
As shown in fig. 11, the electronic device 1100 may include a processing means (e.g., a central processor, a graphics processor, etc.) 1101 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 1102 or a program loaded from a storage means 1108 into a random access Memory (Random Access Memory RAM) 1103. In the RAM 1103, various programs and data necessary for the operation of the electronic device 1100 are also stored. The processing device 1101, ROM 1102, and RAM 1103 are connected to each other by a bus 1104. An input/output (I/O) interface 1105 is also connected to bus 1104.
In general, the following devices may be connected to the I/O interface 1105: input devices 1106 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 1107 including, for example, a Liquid Crystal Display (LCD) CRYSTAL DISPLAY, a speaker, a vibrator, and the like; storage 1108, including for example, magnetic tape, hard disk, etc.; and a communication device 1109. The communication means 1109 may allow the electronic device 1100 to communicate wirelessly or by wire with other devices to exchange data. While fig. 11 illustrates an electronic device 1100 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure 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 a network via communications device 1109, or from storage device 1108, or from ROM 1102. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 1101.
It should be noted that the computer readable medium described in the present disclosure 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 the 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 (EPROM or 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 disclosure, 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 disclosure, 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: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer-readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above-described embodiments.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a local area network (Local Area Network, LAN for short) or a wide area network (Wide Area Network, WAN for short), or may be connected to an external computer (e.g., through the internet using an internet service provider).
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 disclosure. 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 and/or flowchart illustration, and combinations of blocks in the block diagrams and/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.
The units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. The name of the unit does not in any way constitute a limitation of the unit itself, for example the first acquisition unit may also be described as "unit acquiring at least two internet protocol addresses".
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on 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 (EPROM or 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.
There is also provided in an embodiment of the disclosure a computer program product comprising a computer program which, when executed by a processor, implements the method in the embodiments described above.
In a first aspect, according to one or more embodiments of the present disclosure, there is provided a view element state management method, including:
Acquiring a target state behavior of a target view element, wherein the target state behavior is used for determining a change type of a state, and the state is a logic state of the target view element;
in a state management library, determining a target management tool according to the target state behaviors, wherein the state management library comprises a plurality of management tools, and the management tools comprise logic processors which are used for processing the logic relations between the states of the view elements in the management tools and the state behaviors;
and calling the target management tool to process the target state behavior to determine the new state of the target view element.
According to one or more embodiments of the present disclosure, the parameters in the management tool and the logical processor define a parameter type, the parameter type including: at least one of a numerical value, an array, text, and a function;
the parameter type is used for being correctly called when the target management tool is called to process the target state behavior.
According to one or more embodiments of the present disclosure, the state management library further comprises: a logical processor set, a state behavior set, an initial state set, and a management tool set;
the set of logical processors includes the logical processors in each of the management tools;
the set of state behaviors includes the state behaviors in each of the management tools;
the initial state set comprises initial states of the state behaviors;
The set of management tools includes all of the management tools.
In accordance with one or more embodiments of the present disclosure, the determining, in a state management library, a target management tool according to the target state behavior includes:
Determining the target management tool in the state management library through a target pointer of a hook interface component according to the target state behavior;
the hook interface assembly comprises a pointer corresponding to the management tool.
According to one or more embodiments of the present disclosure, the invoking the target management tool to process the target state behavior includes:
And calling the target management tool to process the target state behavior according to the target pointer.
According to one or more embodiments of the present disclosure, the target state behavior includes: the obtaining the target state behavior of the target view element includes:
Acquiring the current state and the target logic behavior through a hook interface component;
Correspondingly, in the state management library, determining a target management tool according to the target state behavior includes:
determining a target pointer corresponding to the target management tool according to the target logic behavior by using the hook interface component, wherein the target pointer is contained in the hook interface component;
And determining the target management tool according to the target pointer and the state management library.
According to one or more embodiments of the present disclosure, when the new state corresponding to the target state behavior is a state shared by multiple view elements, the determining, according to the target logic behavior, a target pointer corresponding to the target management tool includes:
acquiring a context provider of the target pointer according to the target logic behavior;
the target pointer is determined from the context provider.
According to one or more embodiments of the present disclosure, the context provider is configured to provide a connection interface to the state management library and a context component, and the determining the target pointer according to the context provider includes:
Obtaining the context component of the context provider package;
the target pointer is determined from the context component.
In accordance with one or more embodiments of the present disclosure, the invoking the target management tool to process the target state behavior to determine a new state of the target view element includes:
the target state behavior is processed by the target management tool according to the target context component to determine a new state of the target view element.
According to one or more embodiments of the present disclosure, the method further comprises:
And updating and configuring the new state for the target view element through a state assigner.
In accordance with one or more embodiments of the present disclosure, before the updating the configuration of the new state for the target view element by the state assigner, further comprises:
Acquiring a function selector for configuring each parameter in the state assigner and/or a called target configuration model;
The state assigner is configured according to the function selector so that the state assigner meets new state configuration requirements of the target view element.
In a second aspect, according to one or more embodiments of the present disclosure, there is provided a view element state management apparatus including:
The system comprises an acquisition module, a control module and a control module, wherein the acquisition module is used for acquiring target state behaviors of a target view element, wherein the target state behaviors are used for determining the change type of states, and the states are logic states of the target view element;
The state management library module is used for determining a target management tool according to the target state behaviors, wherein the state management library module comprises a plurality of management tools, and the management tools comprise logic processors which are used for processing the logic relations between the states of the view elements in the management tools and the state behaviors;
And the processing module is used for calling the target management tool to process the target state behavior so as to determine the new state of the target view element.
According to one or more embodiments of the present disclosure, the parameters in the management tool and the logical processor define a parameter type, the parameter type including: at least one of a numerical value, an array, text, and a function;
the parameter type is used for being correctly called when the target management tool is called to process the target state behavior.
According to one or more embodiments of the present disclosure, the state management library module further comprises: a logical processor set, a state behavior set, an initial state set, and a management tool set;
the set of logical processors includes the logical processors in each of the management tools;
the set of state behaviors includes the state behaviors in each of the management tools;
the initial state set comprises initial states of the state behaviors;
The set of management tools includes all of the management tools.
According to one or more embodiments of the present disclosure, the state management library module is configured to determine a target management tool according to the target state behavior, and includes:
The state management library module is used for determining at least one target management tool in the state management library through a target pointer of the hook interface component according to the target state behavior;
the hook interface assembly comprises pointers corresponding to the management tools.
According to one or more embodiments of the present disclosure, the processing module, configured to invoke the target management tool to process the target state behavior, includes:
and the processing module is used for calling the target management tool to process the target state behavior according to the target pointer.
According to one or more embodiments of the present disclosure, the target state behavior includes: the obtaining module is configured to obtain a current state of a target behavior object and a target logic behavior, where the obtaining module is configured to obtain a target state behavior of a target view element, and the obtaining module includes:
the acquisition module is used for acquiring the current state and the target logic behavior through a hook interface component;
correspondingly, the state management library module is configured to determine a target management tool according to the target state behavior, and includes:
The state management library module is used for determining a target pointer corresponding to the target management tool according to the target logic behavior by utilizing the hook interface component, and the target pointer is contained in the hook interface component;
the state management library module is further used for determining the target management tool according to the target pointer and the state management library.
According to one or more embodiments of the present disclosure, when the new state corresponding to the target state behavior is a state shared by multiple view elements, the state management library module is configured to determine, according to the target logic behavior, a target pointer corresponding to the target management tool, including:
The state management library module is used for acquiring a context provider of the target pointer according to the target logic behavior;
The state management library module is further configured to determine the target pointer according to the context provider.
According to one or more embodiments of the present disclosure, the context provider is configured to provide a connection interface to the state management library and a context component, and the processing module is configured to determine the target pointer according to the context provider, including:
The processing module is configured to obtain the context component of the context provider package;
the processing module is further configured to determine the target pointer according to the context component.
According to one or more embodiments of the present disclosure, the processing module, configured to invoke the target management tool to process the target state behavior to determine a new state of the target view element, includes:
The processing module is used for calling the target management tool to process the target state behavior according to the target context component so as to determine the new state of the target view element.
According to one or more embodiments of the present disclosure, the view element state management apparatus further includes:
The processing module is further configured to update and configure the new state for the target view element through a state assigner.
In accordance with one or more embodiments of the present disclosure, before the processing module is further configured to update the new state for the target view element by means of a state assigner, the processing module further comprises:
The acquisition module is further used for acquiring a function selector for configuring each parameter in the state assigner and/or the called target configuration model;
The processing module is further configured to configure the state assigner according to the function selector, so that the state assigner meets new state configuration requirements of the target view element.
In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device comprising:
At least one processor and memory;
the memory stores computer-executable instructions;
The at least one processor executes the computer-executable instructions stored by the memory, causing the at least one processor to perform the view element state management method as described above in the first aspect and the various possible designs of the first aspect.
In a fourth aspect, according to one or more embodiments of the present disclosure, there is provided a computer-readable storage medium having stored therein computer-executable instructions which, when executed by a processor, implement the view element state management method as described above in the first aspect and the various possible designs of the first aspect.
In a fifth aspect, according to one or more embodiments of the present disclosure, there is provided a computer program, comprising a computer program, which when executed by a processor, implements the view element state management method as described in the various possible designs of the first aspect above.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to 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 example forms of implementing the claims.
Claims (15)
1. A method for view element state management, comprising:
Acquiring a target state behavior of a target view element, wherein the target state behavior is used for determining a change type of a state, the state is a logic state of the target view element, and the target state behavior comprises a target logic behavior;
In a state management library, determining a target pointer corresponding to a target management tool according to target logic behaviors in the target state behaviors, and determining the target management tool according to the target pointer, wherein the state management library comprises a plurality of management tools, each management tool comprises a logic processor, each logic processor is used for processing a logic relationship between the state and the state behaviors of a view element in the management tool, parameters in the management tool and each logic processor define a parameter type, and the parameter types are used for being correctly called when the target management tool is called to process the target state behaviors;
and calling the target management tool to process the target state behavior to determine the new state of the target view element.
2. The view element state management method according to claim 1, wherein the parameter types include: at least one of a numerical value, an array, text, and a function.
3. The view element state management method according to claim 1 or 2, wherein the state management library further comprises: a logical processor set, a state behavior set, an initial state set, and a management tool set;
the set of logical processors includes the logical processors in each of the management tools;
the set of state behaviors includes the state behaviors in each of the management tools;
the initial state set comprises initial states of the state behaviors;
The set of management tools includes all of the management tools.
4. A method of view element state management according to claim 3, wherein in the state management library, determining a target management tool from the target state behavior comprises:
Determining the target management tool in the state management library through a target pointer of a hook interface component according to the target state behavior;
the hook interface assembly comprises a pointer corresponding to the management tool.
5. The view element state management method of claim 4, wherein the invoking the object management tool to process the object state behavior comprises:
And calling the target management tool to process the target state behavior according to the target pointer.
6. The view element state management method according to claim 1, wherein the target state behavior further comprises: the obtaining the current state of the target behavior object, wherein the obtaining the target state behavior of the target view element comprises:
Acquiring the current state and the target logic behavior through a hook interface component;
Correspondingly, in the state management library, according to the target logic behavior in the target state behavior, determining a target pointer corresponding to a target management tool includes:
and determining a target pointer corresponding to the target management tool according to the target logic behavior by using the hook interface component, wherein the target pointer is contained in the hook interface component.
7. The view element state management method according to claim 6, wherein when the new state corresponding to the target state behavior is a state shared by a plurality of view elements, the determining, by using the hook interface component, a target pointer corresponding to the target management tool according to the target logic behavior includes:
acquiring a context provider of the target pointer according to the target logic behavior;
the target pointer is determined from the context provider.
8. The view element state management method of claim 7, wherein the context provider is configured to provide a connection interface to the state management library and context component, the determining the target pointer according to the context provider comprising:
Obtaining the context component of the context provider package;
the target pointer is determined from the context component.
9. The view element state management method of claim 8, wherein the invoking the target management tool to process the target state behavior to determine a new state of the target view element comprises:
the target state behavior is processed by the target management tool according to a target context component to determine a new state of the target view element.
10. The view element state management method according to any one of claims 1, 6-9, wherein the method further comprises:
And updating and configuring the new state for the target view element through a state assigner.
11. The view element state management method of claim 10, further comprising, prior to the updating the configuration of the new state by the state assigner for the target view element:
Acquiring a function selector for configuring each parameter in the state assigner and/or a called target configuration model;
The state assigner is configured according to the function selector so that the state assigner meets new state configuration requirements of the target view element.
12. A view element state management apparatus, comprising:
the system comprises an acquisition module, a control module and a control module, wherein the acquisition module is used for acquiring target state behaviors of a target view element, the target state behaviors are used for determining the change type of states, the states are logic states of the target view element, and the target state behaviors comprise target logic behaviors;
The state management library module is used for determining a target pointer corresponding to a target management tool according to target logic behaviors in the target state behaviors, and determining the target management tool according to the target pointer, wherein the state management library module comprises a plurality of management tools, each management tool comprises a logic processor, each logic processor is used for processing a logic relationship between the state and the state behaviors of a view element in the management tool, parameters in the management tool and each logic processor define a parameter type, and the parameter types are used for being correctly called when the target management tool is called to process the target state behaviors;
And the processing module is used for calling the target management tool to process the target state behavior so as to determine the new state of the target view element.
13. An electronic device, comprising:
At least one processor and memory;
the memory stores computer-executable instructions;
The at least one processor executing the computer program stored by the memory causes the at least one processor to perform the view element state management method of any of claims 1 to 11.
14. A computer readable storage medium having stored therein computer executable instructions which, when executed by a processor, implement the view element state management method of any of claims 1 to 11.
15. A computer program product comprising a computer program, characterized in that the computer program, when executed by a processor, implements the view element state management method of any of claims 1 to 11.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110013533.3A CN112698824B (en) | 2021-01-06 | 2021-01-06 | View element state management method, device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110013533.3A CN112698824B (en) | 2021-01-06 | 2021-01-06 | View element state management method, device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112698824A CN112698824A (en) | 2021-04-23 |
CN112698824B true CN112698824B (en) | 2024-10-18 |
Family
ID=75514882
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110013533.3A Active CN112698824B (en) | 2021-01-06 | 2021-01-06 | View element state management method, device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112698824B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113377870B (en) * | 2021-06-21 | 2024-07-16 | 京东方科技集团股份有限公司 | Shared data storage method, device and equipment |
CN114567623B (en) * | 2022-02-20 | 2023-09-08 | 中国银联股份有限公司 | Page display method and device |
CN115545213B (en) * | 2022-10-13 | 2023-04-18 | 北京鼎成智造科技有限公司 | Modeling method and device based on graphical behavior tree and reinforcement learning |
CN116610319B (en) * | 2023-06-06 | 2024-05-14 | 易智瑞信息技术有限公司 | A method and system for building map applications based on a low-code platform |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109597611A (en) * | 2018-11-29 | 2019-04-09 | 北京京东尚科信息技术有限公司 | Front end data flow control Components Development system, method, equipment and storage medium |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2010182287A (en) * | 2008-07-17 | 2010-08-19 | Steven C Kays | Intelligent adaptive design |
US8296723B2 (en) * | 2008-12-11 | 2012-10-23 | International Business Machines Corporation | Configurable unified modeling language building blocks |
-
2021
- 2021-01-06 CN CN202110013533.3A patent/CN112698824B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109597611A (en) * | 2018-11-29 | 2019-04-09 | 北京京东尚科信息技术有限公司 | Front end data flow control Components Development system, method, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN112698824A (en) | 2021-04-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112698824B (en) | View element state management method, device, electronic equipment and storage medium | |
CN109523187B (en) | Task scheduling method, device and equipment | |
CN110489101B (en) | Interface simulation method, system, medium and electronic equipment | |
US9805114B2 (en) | Composable selection model through reusable component | |
CN109634490B (en) | List display method, device, equipment and storage medium | |
CN111488285B (en) | Interface testing method, device, electronic equipment and computer readable storage medium | |
CN109857486B (en) | Method, device, equipment and medium for processing program page data | |
CN113377365A (en) | Code display method, device, equipment, computer readable storage medium and product | |
CN110727869A (en) | Page construction method and device | |
CN110704050B (en) | Module initializing method and device, electronic equipment and computer readable storage medium | |
CN115145560A (en) | Business orchestration method, device, equipment, computer readable medium and program product | |
CN115357350A (en) | Task configuration method and device, electronic equipment and computer readable medium | |
CN111625692B (en) | Feature extraction method, device, electronic equipment and computer readable medium | |
CN113296762B (en) | Page embedding method and device, storage medium and electronic equipment | |
CN111625326B (en) | Task pipeline execution method and device and electronic equipment | |
CN110795194B (en) | Desktop display control method, device, terminal and storage medium | |
CN111381813A (en) | Front-end page debugging method and device, computer equipment and storage medium | |
CN118276856B (en) | Application state management method and device, electronic equipment and storage medium | |
CN112364050B (en) | Method, device, electronic equipment and storage medium for acquiring time period based on time control | |
CN110704782A (en) | Page response method and device, electronic equipment and storage medium | |
US20240394122A1 (en) | Interaction event response method and apparatus, electronic device and storage medium | |
CN112346728B (en) | Device adaptation method, apparatus, device and computer readable medium | |
CN110647405A (en) | System message processing method, electronic device, and computer-readable storage medium | |
CN113448550B (en) | Method and device for realizing collection management of classes, electronic equipment and computer medium | |
WO2023273617A1 (en) | Engine capability-based entity function implementation method and apparatus and electronic device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |