Specific embodiment
Single page application is a kind of special Web page application.All activities are confined in a Web page by it, only
The Web page initialization when load corresponding HTML, CSS (Cascading Style Sheets, cascading style sheets) and
JavaScript, activities are all controlled by JavaScript.Once page load completes, single page application will not be because of use
The operation at family and carry out reloading or jumping for the page, instead added using the dynamic control assembly of JavaScript
It carries and unloads, to realize the interaction of UI and user.
A large amount of components are generally comprised especially for the single page application of monitoring type for traditional single page application at present,
It is required to realize automatic refresh function, and current single page generally passes through refresh tasks using each component and realizes automatic refresh function.
As shown in Figure 1, be a single page schematic diagram of application structure, include 4 components, respectively component A, component B, component C, component D, often
A component can realize automatic refresh function by refresh tasks, and general single page is applied and gives refresh tasks to component sheet
Body is managed, and assembly management refresh tasks are broadly divided into three parts: when component loads, component itself opens refreshing first
Task;Then when external event triggers (such as Parameters variation), component needs voluntarily to handle, and executes a refresh tasks to protect
Demonstrate,prove data consistency;Secondly when component unloading, component itself cancels refresh tasks.So for component A, component B, component C,
Component D, each component itself manage refresh tasks, and encoder complexity is higher, can expend developer's more time accordingly
And energy.
In view of the above-mentioned problems, this specification embodiment provides a kind of technical solution, task is pre-configured in single page application
Administrative center is managed collectively refresh tasks, as shown in Fig. 2, showing for a kind of single page application structure that this specification embodiment provides
It is intended to, includes 4 components, respectively component A, component B, component C, component D, task management center unified management component A, component
B, the refresh tasks of component C, component D, the data maintenance task that can be will be dispersed in each component is unitized, can effectively drop
Low encoder complexity can also reduce time and efforts spent by developer accordingly.
The technical solution that specific this specification embodiment provides is as follows:
When receiving the refresh tasks register instruction of any component transmission, task management center is established corresponding refresh and is appointed
Business;When external event triggering, task management center accesses each component for currently including in the single page application, obtains described outer
Portion's event triggers generated parameter current information;According to the parameter current information, it is the list that task management center, which executes,
The established corresponding refresh tasks of each component for currently including in page application, so as to currently include in single page application
Each component obtain the corresponding latest data of the parameter current information;When the refresh tasks for receiving any component transmission are cancelled
When instruction, task management center removes corresponding refresh tasks.
In order to make those skilled in the art more fully understand the technical solution in this specification embodiment, below in conjunction with this
Attached drawing in specification embodiment is described in detail the technical solution in this specification embodiment, it is clear that described
Embodiment is only a part of the embodiment of this specification, instead of all the embodiments.The embodiment of base in this manual,
Those of ordinary skill in the art's every other embodiment obtained, all should belong to the range of protection.
As shown in figure 3, be the implementation flow chart of the management method for the refresh tasks that this specification embodiment provides, it is specific
It may comprise steps of:
The refresh tasks management method that wherein this specification embodiment provides is broadly divided into three parts, respectively refreshes and appoints
Business is established, refresh tasks execute and refresh tasks remove, and is illustrated separately below:
Refresh tasks establish part:
S301, when receiving the refresh tasks register instruction of any component transmission, task management center is established corresponding
Refresh tasks;
In the present specification, when component, which loads, to be completed, refresh tasks register instruction can be sent to task management center, it is right
For task management center, it is likely to be received the refresh tasks register instruction of any component transmission, when receiving any component
When the refresh tasks register instruction of transmission, it is meant that the refresh tasks register instruction is issued in the case where component is loaded and completed
, task management center (such as task pool) can establish corresponding refresh tasks directly in a reservoir.
Component A as shown in Figure 2, component B, component C, component D, single page application initialization charging assembly A, component B, component
C, component D, once component A, component B, component C, component D load complete, component A, component B, component C, component D can respectively to
Task management center sends refresh tasks register instruction, when task management center receives component A, component B, component C, component D
When the refresh tasks register instruction sent respectively, then it can establish and component A, component B, component C, the corresponding refreshing of component D
Task.
Preferably, it is established before corresponding refresh tasks in a reservoir, searches whether that there are corresponding are in not to depend on shape
The refresh tasks of state, if it does not exist, task management center establish corresponding refresh tasks in a reservoir, and if it exists, will then correspond to
Attached in container again in the refresh tasks for not depending on state, it is not necessary to establish corresponding refresh tasks.Here in not
The refresh tasks for depending on state are the refresh tasks for not depending on container, and state is unavailable.
Refresh tasks execution part:
S302, when external event triggering, task management center accesses each component for currently including in the single page application,
It obtains the external event and triggers generated parameter current information;
After by above-mentioned steps S301, each component for currently including in single page application has been established corresponding refresh and appoints
Business needs to be implemented the corresponding refresh tasks of each component when external event triggering, to guarantee data consistency, will be dispersed in each
Data maintenance task in component is unitized.
External event can be parameter change, page change, timed task etc., such as single page application, display nearest 5
Data in it, user's adjustment time parameter, the data in display nearest 7 days, in another example every for the component in single page application
It is spaced 5 seconds and refreshes once.When the triggering of said external event, before executing the corresponding refresh tasks of each component, in order to protect
Data consistency is demonstrate,proved, task management center needs to access each component for currently including in single page application, obtains said external event
Parameter current information caused by triggering, such as by taking parameter change as an example, user's adjustment time parameter, in display nearest 7 days
Data, for task management center, in this case it is not apparent which 7 days this 7 days be specifically, therefore then task management center needs to access
Each component in single page application, obtains the parameter current information as caused by adjustment time parameter, that is, determines that this 7 days are specifically which
7 days.
Preferably, when external event triggers, said external thing is determined from each component for currently including in single page application
Part triggers the component being directed to, and current ginseng caused by the triggering of said external event is obtained from the component that external event triggering is directed to
Number information.
Such as component A as shown in Figure 2, component B, component C, component D, the object that external event triggering is directed to is component A,
The object that task management center determines that external event triggering is directed to from said modules A, component B, component C, component D is component A,
Said external event can be then obtained from component A triggers generated parameter current information.
S303, according to the parameter current information, task management center, which executes in the single page application, currently includes
Each established corresponding refresh tasks of component, so as to work as described in each component acquisition for currently including in single page application
The corresponding latest data of preceding parameter information;
For parameter current information obtained in S302, can be executed according to the parameter information, task management center
For the established corresponding refresh tasks of each component for currently including in single page application, then each component can refresh once,
The corresponding latest data of parameter current information is obtained, can so guarantee data consistency in each component.
Such as component A as shown in Figure 2, component B, component C, component D, current time parameter obtained in S302 is believed
Breath is 2017-01-05 to 2017-01-12, and according to the time parameter information, task management center can be executed as component A, group
The established corresponding refresh tasks of part B, component C, component D, each self-refresh one of component A, component B, component C, component D
Secondary, component A, component B, component C, component D respectively obtain the corresponding latest data of 2017-01-05 to 2017-01-12, so may be used
So that the time range for the data that component A, component B, component C, component D are shown is 2017-01-05 to 2017-01-12, guarantee
Data consistency.
Refresh tasks remove part:
S304, when the refresh tasks for receiving any component transmission cancel instruction, task management center removes corresponding
Refresh tasks.
Since each refresh tasks correspond to unique component, each component has the life cycle of itself, therefore works as component
When starting unloading, refresh tasks are sent to task management center and cancel instruction, for task management center, when reception is taken office
When the refresh tasks that one component is sent cancel instruction, the refresh tasks cancellation instruction that can learn that any component is sent is any
Component starts the refresh tasks sent in the case where unloading and cancels instruction, removes corresponding refresh tasks from container, makes to be moved
The refresh tasks removed are in and do not depend on state, i.e., do not depend on container, and state is unavailable.
Such as component A as shown in Figure 2, component B, component C, component D, refresh when component A is sent to task management center
When task cancels instruction, task management center receives the instruction, removes the corresponding refresh tasks of component A from container, makes at its
It is subsequent when component A reloads completion in not depending on state, the refresh tasks register instruction of component A transmission is received, directly
It is attached in container again in the refresh tasks for not depending on state by component A is corresponding, state is available at this time, it is not necessary to again
Re-establish the corresponding refresh tasks of component A.
By the description of the above-mentioned technical solution provided this specification embodiment, task is pre-configured in single page application
Administrative center, task management center can be managed collectively refresh tasks: when the refresh tasks registration for receiving any component transmission
When instruction, task management center establishes corresponding refresh tasks;When external event triggering, task management center access single page is answered
Each component for currently including in, obtain external event trigger caused by parameter current information, according to the current parameter information,
Executing is the established corresponding refresh tasks of each component for currently including in single page application, so that current in single page application
Each component for including obtains the corresponding latest data of parameter current information;When the refresh tasks for receiving any component transmission are cancelled
When instruction, task management center removes corresponding refresh tasks.Appoint in this way, which task management center can be managed collectively refreshing
Business can make the data maintenance task being dispersed in each component unitized, can be effectively reduced encoder complexity, accordingly
Time and efforts spent by developer can be reduced.
Relative to above method embodiment, this specification embodiment also provides a kind of managing device of refresh tasks, referring to
Shown in Fig. 4, which be can specifically include: configuration module 410, task creation module 420, data obtaining module 430, task are held
Row module 440, task remove module 450.
Configuration module 410, for being pre-configured with task management center in single page application;
Task creation module 420, for when receive any component transmission refresh tasks register instruction when, task management
Corresponding refresh tasks are established at center;
Data obtaining module 430, for when external event triggering, task management center access in single page application when
The preceding each component for including obtains the external event and triggers generated parameter current information;
Task execution module 440, for according to the parameter current information, it to be that the single page is answered that task management center, which executes,
The established corresponding refresh tasks of each component for currently including in, so that currently include in single page application is each
Component obtains the corresponding latest data of the parameter current information;
Task remove module 450, for when receive any component transmission refresh tasks cancel instruction when, task management
Center removes corresponding refresh tasks.
In a kind of specific embodiment of this specification, the data obtaining module 430 is specifically used for:
When external event triggering, external event triggering needle is determined from each component for currently including in single page application
Pair component;
The external event is obtained from the component that external event triggering is directed to triggers generated parameter current information.
In a kind of specific embodiment of this specification, the task creation module 420 is specifically used for:
When receiving the refresh tasks register instruction of any component transmission, search whether that there are corresponding are in not to depend on
The refresh tasks of state;
If it does not exist, task management center establishes corresponding refresh tasks in a reservoir, otherwise by it is corresponding in not according to
The refresh tasks of attached state attach in container again.
In a kind of specific embodiment of this specification, the task remove module 450 is specifically used for:
When the refresh tasks for receiving any component transmission cancel instruction, task management center is removed from the container
Corresponding refresh tasks are in removed refresh tasks and do not depend on state.
In a kind of specific embodiment of this specification,
The refresh tasks register instruction that any component is sent is sent in the case where any component is loaded and completed
Refresh tasks register instruction;
It is to start to send in the case where unloading in any component that the refresh tasks that any component is sent, which cancel instruction,
Refresh tasks cancel instruction.
The function of modules and the realization process of effect are specifically detailed in the above method and correspond to step in above-mentioned apparatus
Realization process, details are not described herein.
By the description of the above-mentioned technical solution provided this specification embodiment, task is pre-configured in single page application
Administrative center, task management center can be managed collectively refresh tasks: when the refresh tasks registration for receiving any component transmission
When instruction, task management center establishes corresponding refresh tasks;When external event triggering, task management center access single page is answered
Each component for currently including in, obtain external event trigger caused by parameter current information, according to the current parameter information,
Executing is the established corresponding refresh tasks of each component for currently including in single page application, so that current in single page application
Each component for including obtains the corresponding latest data of parameter current information;When the refresh tasks for receiving any component transmission are cancelled
When instruction, task management center removes corresponding refresh tasks.Appoint in this way, which task management center can be managed collectively refreshing
Business can make the data maintenance task being dispersed in each component unitized, can be effectively reduced encoder complexity, accordingly
Time and efforts spent by developer can be reduced.
This specification embodiment also provides a kind of computer equipment, as shown in figure 5, the equipment may include: processor
510, memory 520, input/output interface 530, communication interface 540 and bus 550.Wherein processor 510, memory 520,
Input/output interface 530 and communication interface 540 pass through the communication connection between the realization of bus 550 inside equipment.
Processor 510 can use general CPU (Central Processing Unit, central processing unit), micro process
Device, application specific integrated circuit (Application Specific Integrated Circuit, ASIC) or one or
The modes such as multiple integrated circuits are realized, for executing relative program, to realize technical solution provided by this specification embodiment.
Memory 520 can use ROM (Read Only Memory, read-only memory), RAM (Random Access
Memory, random access memory), static storage device, the forms such as dynamic memory realize.Memory 520 can store
Operating system and other applications are realizing technical solution provided by this specification embodiment by software or firmware
When, relevant program code is stored in memory 520, and execution is called by processor 510.
Input/output interface 530 is for connecting input/output module, to realize information input and output.Input and output/
Module can be used as component Configuration (not shown) in a device, can also be external in equipment to provide corresponding function.Wherein
Input equipment may include keyboard, mouse, touch screen, microphone, various kinds of sensors etc., output equipment may include display,
Loudspeaker, vibrator, indicator light etc..
Communication interface 540 is used for connection communication module (not shown), to realize the communication of this equipment and other equipment
Interaction.Wherein communication module can be realized by wired mode (such as USB, cable etc.) and be communicated, can also be wirelessly
(such as mobile network, WIFI, bluetooth etc.) realizes communication.
Bus 550 includes an access, in various components (such as the processor 510, memory 520, input/output of equipment
Interface 530 and communication interface 540) between transmit information.
It should be noted that although above equipment illustrates only processor 510, memory 520, input/output interface
530, communication interface 540 and bus 550, but in the specific implementation process, which can also include realizing to operate normally
Necessary other assemblies.In addition, it will be appreciated by those skilled in the art that, it can also be only comprising realizing in above equipment
Component necessary to this specification example scheme, without including all components shown in figure.
This specification embodiment also provides a kind of computer readable storage medium, is stored thereon with computer program, the journey
The management method of refresh tasks above-mentioned is realized when sequence is executed by processor.This method includes at least:
A kind of management method of refresh tasks is applied to single page application, is pre-configured with task pipe in single page application
Reason center, this method comprises:
When receiving the refresh tasks register instruction of any component transmission, task management center is established corresponding refresh and is appointed
Business;
When external event triggering, task management center accesses each component for currently including in the single page application, obtains
The external event triggers generated parameter current information;
According to the parameter current information, it is each component for currently including in single page application that task management center, which executes,
Established corresponding refresh tasks, so that each component for currently including in single page application obtains the parameter current
The corresponding latest data of information;
When the refresh tasks for receiving any component transmission cancel instruction, task management center removes corresponding refresh and appoints
Business.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media, can be by any side
Method or technology realize that information stores.Information can be computer readable instructions, data structure, the module of program or other numbers
According to.The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory
(SRAM), dynamic random access memory (DRAM), other kinds of random access memory (RAM), read-only memory
(ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory techniques, CD-ROM are read-only
Memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or
Other magnetic storage devices or any other non-transmission medium, can be used for storage can be accessed by a computing device information.According to
Herein defines, and computer-readable medium does not include temporary computer readable media (transitory media), such as modulation
Data-signal and carrier wave.
As seen through the above description of the embodiments, those skilled in the art can be understood that this specification
Embodiment can be realized by means of software and necessary general hardware platform.Based on this understanding, this specification is implemented
Substantially the part that contributes to existing technology can be embodied in the form of software products the technical solution of example in other words,
The computer software product can store in storage medium, such as ROM/RAM, magnetic disk, CD, including some instructions are to make
It is each to obtain computer equipment (can be personal computer, server or the network equipment etc.) execution this specification embodiment
Method described in certain parts of a embodiment or embodiment.
System, device, module or the unit that above-described embodiment illustrates can specifically realize by computer chip or entity,
Or it is realized by the product with certain function.A kind of typically to realize that equipment is computer, the concrete form of computer can
To be personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media play
In device, navigation equipment, E-mail receiver/send equipment, game console, tablet computer, wearable device or these equipment
The combination of any several equipment.
All the embodiments in this specification are described in a progressive manner, same and similar portion between each embodiment
Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.Especially for device reality
For applying example, since it is substantially similar to the method embodiment, so describing fairly simple, related place is referring to embodiment of the method
Part explanation.The apparatus embodiments described above are merely exemplary, wherein described be used as separate part description
Module may or may not be physically separated, can be each module when implementing this specification example scheme
Function realize in the same or multiple software and or hardware.Can also select according to the actual needs part therein or
Person's whole module achieves the purpose of the solution of this embodiment.Those of ordinary skill in the art are not the case where making the creative labor
Under, it can it understands and implements.
The above is only the specific embodiment of this specification embodiment, it is noted that for the general of the art
For logical technical staff, under the premise of not departing from this specification embodiment principle, several improvements and modifications can also be made, this
A little improvements and modifications also should be regarded as the protection scope of this specification embodiment.