CN106484459A - It is applied to flow control method and the device of JavaScript - Google Patents
It is applied to flow control method and the device of JavaScript Download PDFInfo
- Publication number
- CN106484459A CN106484459A CN201610819490.7A CN201610819490A CN106484459A CN 106484459 A CN106484459 A CN 106484459A CN 201610819490 A CN201610819490 A CN 201610819490A CN 106484459 A CN106484459 A CN 106484459A
- Authority
- CN
- China
- Prior art keywords
- business
- type
- defineproperty
- monitored
- data
- 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.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Transfer Between Computers (AREA)
- Stored Programmes (AREA)
Abstract
Present disclose provides being applied to flow control method and the device of JavaScript.The method includes:Initiate AJAX request, obtain data and simultaneously give one or more global variables, wherein, one or more of global variables be according to set by the trigger event of at least one business;For each business at least one business, the global variable according to set by the trigger event of the business is monitored, and when the global variable set by the trigger event according to the business changes, triggers the execution of the business.The application disclosure, can realize event and trigger indirectly business, be conducive to the Row control of abbreviation and decoupling JavaScript, depositing in the case of polling, also helping minimizing wrap count, mitigating the burden of internal memory.
Description
Technical field
It relates to internet arena, more particularly to a kind of flow control method for being applied to JavaScript and one kind
It is applied to the flow control device of JavaScript.
Background technology
At present in JavaScript (abbreviation JS), using the trigger mechanism based on event, i.e. event triggering business, business
In response to event, service logic is executed using call back function.One business may be in response to multiple events, and an event also may be used
Multiple business can be triggered, therefore, in multiple service response in the case of multiple events, its control logic is often extremely complex.
Additionally, the execution of some business, it is also possible to cause the change of some state-events, and then trigger other business, cause between business
Mutual control coupled to each other, more exacerbates the complexity of Row control.These factors may cause the final stream that realizes in JS
Process control is extremely complex and chaotic so that its realize difficulty increase, and be very easy to error, and cause code legibility and can
Maintainability is poor, is difficult to debug after error.In addition Row control coupled to each other, complicated leads one and starts whole body so that
Technical staff is difficult to the Row control to having realized and is adjusted and upgrades.
Content of the invention
In view of this, disclosure technical problem to be solved is to realize clear logic in JavsScript, be more easy to realize
With the Row control that safeguards.
In order to solve above-mentioned technical problem, according to an aspect of this disclosure, there is provided one kind is applied to JavaScript
Flow control method, the method includes:AJAX request is initiated, is obtained data and one or more global variables is given, wherein,
One or more of global variables be according to set by the trigger event of at least one business;For at least one industry
Each business in business, monitors the global variable according to set by the trigger event of the business, and in touching according to the business
When global variable set by the event of sending out changes, the execution of the business is triggered.
According to another aspect of the disclosure, a kind of flow control device for being applied to JavaScript is additionally provided, should
Device includes:Global variable assignment unit, is configured to initiate AJAX request, obtains data and gives one or more global changes
Amount, wherein, one or more of global variables be according to set by the trigger event of at least one business;Monitor triggering single
Unit, is configured to, for each business at least one business, monitor according to set by the trigger event of the business
Global variable, and when the global variable set by the trigger event according to the business changes, trigger holding for the business
OK.
Various aspects of the disclosure, global variable are provided as the interval between event and business, and business only needs to monitor
Whether global variable changes and need not be concerned about event itself, changes trigger mechanism of traditional JS based on event, direct from event
Triggering business is changed to event and triggers business indirectly, being capable of abbreviation and decoupling Row control.And, event only changes global variable,
And need not be concerned about which business the change of these global variables will trigger, it is possible to increase carry the efficiency of data.According to the disclosure
The Row control for being applied to JS, the clear readability of its control logic, facilitate implementation and safeguard.
According to below with reference to the accompanying drawings to detailed description of illustrative embodiments, the further feature of the disclosure and aspect will become
Clear.
Description of the drawings
Comprising in the description and accompanying drawing and the specification of the part that constitutes specification together illustrates the disclosure
Exemplary embodiment, feature and aspect, and for explaining the principle of the disclosure.
Fig. 1 shows the flow process of the flow control method for being applied to JavaScript of the one embodiment according to the disclosure
Figure.
Fig. 2 shows the structure of the flow control device for being applied to JavaScript of the one embodiment according to the disclosure
Block diagram.
Fig. 3 shows a kind of knot of Row control equipment for being applied to JavaScript of another embodiment of the disclosure
Structure block diagram.
Fig. 4 shows the Row control schematic diagram that traditional JS page is loaded.
Fig. 5 shows the Row control schematic diagram of traditional JS page business coupled to each other in loading.
Fig. 6 shows the Row control schematic diagram loaded according to the JS page of the disclosure.
Fig. 7 shows the schematic diagram of the non-core module for playing the page according to the loading of the disclosure.
Fig. 8 shows the Row control schematic diagram of the barrage business based on AJAX poll according to the disclosure.
Fig. 9 shows the multiple services Row control schematic diagram in traditional JS based on AJAX poll.
Figure 10 shows the multiple services Row control schematic diagram based on AJAX poll according to the disclosure.
Specific embodiment
Describe various exemplary embodiments, feature and the aspect of the disclosure below with reference to accompanying drawing in detail.Identical in accompanying drawing
Reference represent the same or analogous element of function.The various aspects of embodiment are although shown in the drawings, but are removed
Non-specifically is pointed out, it is not necessary to accompanying drawing drawn to scale.
Special word " exemplary " means " as example, embodiment or illustrative " here.Here as " exemplary "
Illustrated any embodiment is should not necessarily be construed as preferred or advantageous over other embodiments.
In addition, in order to better illustrate the disclosure, giving numerous details in specific embodiment below.
It will be appreciated by those skilled in the art that without some details, the disclosure can equally be implemented.In some instances, for
Method well known to those skilled in the art, means, element and circuit are not described in detail, in order to highlight the purport of the disclosure.
Herein, first general principle of this disclosure is simply introduced.
If there are 3 elements A, B, C in window, all assume white, current demand is:When window becomes big and is more than 200px
When (pixel, pixel), it is desirable to which A becomes red, and B becomes green, and C becomes purple;When window width is less than 200px,
It is required that A, B, C all assume white.According to traditional trigger mechanism based on event, the false code for realizing the demand is as follows:
At present, it is substantially in JS and is realized by said method.In some cases, if meeting specified conditions, go back
Can consider to mediate AitemChange, BitemChange, CitemChange in a function.
If now proposing new demand:It is required that D element also can change colour with the change of window size, be then referred to
Make A, B, the implementation of C element discoloration, new increasing function DitemChange.
But will, if newly-increased demand is more and more what if?Object is more and more to become increasingly complex, windowChange
Function can become more and more huger, and the technical staff of maintenance and management windowChange function can have found:Wrap in this function
Multiple events and multiple service logics is included, needs in maintenance process to go deep into the inside of each event and service logic, one by one really
Determine the response relation between event and business, workload and work difficulty are all very big, and easily malfunction, and are also difficult to adjust after error
Examination.
Even further, demand is proposed:Element E, not only requires to become crocus when window is more than 700px, also
To change colour after 5 seconds after element A discoloration, according to above-mentioned solution pattern, not only will consider windowChange function,
AitemChange to be considered, it is therefore desirable to writing in two functions to the control of E element so that control logic is increasingly complex.
Inventor has found, is that event changes some states based on the essence of the trigger mechanism of event, and business is (generally to return
The form of letter of transfer number) it is performed in response to the change of these states, therefore, it can consider to arrange these states of triggering business
For global variable, global variable becomes the interval between event and business.So as to event only changes global variable, without concern for this
Which business the change of a little global variables can trigger;Business is only concerned about whether the global variable that can trigger the business changes,
Without concern for event itself.
Based on this inventive concept, the false code for realizing the demand can be converted into:
Based on above-mentioned thinking, once window size is changed, global variable GlobalWindowchangeFlag sends out
Changing;And GlobalWindowchangeFlag once changes, at once notify AitemChange, BitemChange,
The a series of function such as CitemChange, EitemChange, makes corresponding response.
Embodiment 1
Fig. 1 shows the flow process of the flow control method for being applied to JavaScript of the one embodiment according to the disclosure
Figure.In the present embodiment, the method includes:
Step 101, initiates AJAX request, obtains data and simultaneously gives one or more global variables, wherein, one or
Multiple global variables be according to set by the trigger event of at least one business;
Step 103, for each business at least one business, monitors according to set by the trigger event of the business
The global variable that puts, and when the global variable set by the trigger event according to the business changes, trigger the business
Execution.
In the present embodiment, global variable is provided as the interval between event and business, and business need to only monitor global change
The change of amount and event itself need not be concerned about, change trigger mechanism of traditional JS based on event, directly trigger business from event
It is changed to event and triggers business indirectly, being capable of abbreviation and decoupling Row control.And, event only changes global variable, and without the need for closing
Which business the change of these global variables of the heart will trigger, it is possible to increase carry the efficiency of data.Being applied to according to embodiment
The Row control of JS, the clear readability of its control logic, facilitate implementation and safeguard.
In a kind of possible embodiment, in above-mentioned steps 103, monitor according to set by the trigger event of the business
Global variable can include:In the case that prototype function Object.defineProperty supported by browser, can adopt
Object.defineProperty monitors the global variable according to set by the trigger event of the business.
The data type of JS can be divided into basic data type and data splitting type.Data splitting type includes JSON again
Type and ARRAY (array) type, wherein, ARRAY type can be divided into the ARRAY type on basis and the ARRAY class of non-basic
Type.The ARRAY type on basis refers to that each element of the ARRAY is basic data type;The ARRAY type of non-basic refers to this
Certain element of ARRAY is data splitting type, and for example, its certain element itself is also ARRAY, and it is embedding that such case also becomes
The ARRAY of set, and/or its certain element is JSON type.
For example, for basic data type, can be directly by prototype function Object.defineProperty
Get method and set method are monitored.It is below the pseudo-code example demonstration of the monitoring basic data type according to the disclosure:
In the console of browser, test code is as follows:
obj.name;
undefined
Obj.name=' Hello World!The window of ' // now ejects alert bullet frame
obj.name
Hello World!
For the ARRAY type on the basis in data splitting type, the existing prototype letter which can be modified in JS
Number, the prototype function for being usually used in changing ARRAY categorical data are as shown in the table:
For changing the prototype function of ARRAY Type Value in table 1JS
But the modification that ARRAY TYPE data element is carried out monitored cannot be arrived by above-mentioned prototype function, and if weight
The function of modification ARRAY categorical data is newly write, and its execution efficiency is extremely difficult to the level of prototype function.
For such case, inventor considers, for the ARRAY type on the basis in data splitting type, can be by original
Value method in type function Object.defineProperty is monitored, also, can call in value method for
Change the prototype function (can be found in table 1) of ARRAY data type data value, to realize while execution efficiency is ensured monitoring.
It is below the pseudo-code example demonstration of the ARRAY type for monitoring basis according to the disclosure:
For the JSON type in data splitting type and the ARRAY type of non-basic, step-by-step recursion can be first passed through and divided
Solution, until decompose the ARRAY type on the basis during all elements for obtaining are basic data type or data splitting type,
And the monitoring scope of partly or entirely including in these elements is monitored, listen only to part or to all monitoring,
Can be arranged as required to.Monitoring to basic data type and the ARRAY type on basis, can refer to above-described side
Method.It is below the pseudo-code example demonstration monitored by whole elements of JSON type according to the disclosure:
For description briefly, assume in above-mentioned example demonstration that finally decomposing the element for obtaining is basic data type, does not examine
Consider the situation for finally decomposing the ARRAY type based on the element for obtaining, it will be appreciated by persons skilled in the art that for most
Decompose the situation of the ARRAY type of existence foundation in the element for obtaining eventually, its realization is similar.Similarly, can be using similar
Method is realized the recurrence of the ARRAY type to non-basic and is monitored.
The monitoring of above-mentioned various data types will can be encapsulated in same function.For example, it is possible to defined function:
DataListener (_ var, callBack (newData, oldDate), KeyList), wherein:_ var represents monitored change
Amount name;Callback represents call back function, and newData, oldDate therein represent the placeholder of new data and legacy data, can
With used in call back function;KeyList represents global variable to be monitored, especially, for the data of data splitting type,
Which element that will be monitored in the data can be arranged by KeyList.For example, for JSON categorical data A as follows:
If only needing to monitor element " B, C " and " E ", without monitoring element " B, D ", then can be by KeyList
Be set to " B, C | D ".The rule of Keylist is with " | " segmentation different pieces of information block herein, represents data with English subscript ', ' number
Level.
In a kind of possible embodiment, prototype function Object.defineProperty is not supported in browser
In the case of, can be with global variable of the automatic regular polling according to set by the trigger event of the business to be monitored.As this area skill
Art personnel understood, and prototype function Object.defineProperty is ECS5 attribute, so not supporting IE8 and being less than
Other IE versions of IE8.Therefore, for such case, variate-value can be obtained using automatic regular polling.Be below according to the disclosure
By automatic regular polling carry out global variable monitoring pseudo-code example demonstration:
If the time interval of automatic regular polling is too short, cpu load is excessive;If interval is oversize, cannot find in time
Data variation, in some instances it may even be possible to omit some data variation.Therefore, the time interval of automatic regular polling rationally can be set as needed.
Compared to prototype function Object.defineProperty, more internal memories can be taken using automatic regular polling, but its can solve the problem that clear
The compatible problem of device of looking at.
Embodiment 2
Fig. 2 shows the flow control device 500 for being applied to JavaScript according to an embodiment of the invention
Structured flowchart.Device 200 includes global variable assignment unit 201 and monitors trigger element 203.Global variable assignment unit 201
It is configured to AJAX request is initiated, obtains data and one or more global variables are given, wherein, one or more of overall situations
Variable be according to set by the trigger event of at least one business.Monitor trigger element 203 be configured to for described at least
Each business in one business, monitors the global variable according to set by the trigger event of the business, and according to the industry
When global variable set by the trigger event of business changes, the execution of the business is triggered.
In a kind of possible embodiment, monitoring trigger element 203 can also include that the first monitoring subelement (does not show
Go out).The first monitoring subelement can be configured to support prototype function Object.defineProperty in browser
In the case of, the global variable according to set by the trigger event of the business is monitored using Object.defineProperty.
For example, the first monitoring subelement can be configured to execute at least one of following:
For basic data type, directly by the get method in prototype function Object.defineProperty and
Set method is monitored;
For the ARRAY type on the basis in data splitting type, by prototype function Object.defineProperty
In value method monitored, wherein, call the prototype for changing ARRAY data type data value in value method
Function;
For the JSON type in data splitting type and the ARRAY type of non-basic, institute is decomposed to by step-by-step recursion
The ARRAY type on the basis in having element to be basic data type or data splitting type, and in all elements
Partly or entirely monitored, wherein, for basic data type, directly pass through prototype function
Get method and set method in Object.defineProperty is monitored;For the basis in data splitting type
ARRAY type, is monitored by the value method in prototype function Object.defineProperty, wherein, in value
The prototype function for changing ARRAY data type data value is called in method.
In a kind of possible embodiment, monitoring trigger element 203 can also include that the second monitoring subelement (does not show
Go out).Second monitoring subelement can be configured to not support the feelings of prototype function Object.defineProperty in browser
Under condition, global variable of the automatic regular polling according to set by the trigger event of the business is to be monitored.
Embodiment 3
Fig. 3 shows a kind of Row control equipment 300 for being applied to JavaScript of another embodiment of the disclosure
Structured flowchart.Equipment 300 can be possess the host server of computing capability, personal computer PC or portable just
Take formula computer or terminal etc..Disclosure specific embodiment is not limited to implementing for calculate node.
Equipment 300 includes processor (processor) 310, communication interface (Communications Interface)
320th, memory (memory) 330 and bus 340.Wherein, processor 310, communication interface 320 and memory 330 are by total
Line 340 completes mutual communication.
Communication interface 320 is used for and network device communications, and wherein the network equipment includes such as Virtual Machine Manager center, shares
Storage etc..
Processor 310 is used for configuration processor.Processor 310 is probably a central processor CPU, or special integrated
Circuit ASIC (Application Specific Integrated Circuit), or be arranged to implement disclosure reality
Apply one or more integrated circuits of example.
Memory 330 is used for depositing file.Memory 330 may include high-speed RAM memory, it is also possible to also include non-easy
The property lost memory (non-volatile memory), for example, at least one magnetic disc store.Memory 330 can also be storage
Device array.Memory 330 is also possible to by piecemeal, and described piece can be combined into virtual volume by certain rule.
In a kind of possible embodiment, said procedure can be the program code for including computer-managed instruction.The journey
Sequence is particularly used in and executes the flow control method for being applied to JavaScript as described in Example 1.
Application example
The page is loaded
Fig. 4 shows the Row control schematic diagram that traditional JS page is loaded.As illustrated, being directed to business 1, sending AJAX please
Ask from server obtain data and give function built-in variable d11, function built-in variable d12 ..., business 1 is in response to function
The changes of function built-in variable such as built-in variable d11, function built-in variable d12 and be performed;For business 2, sending AJAX please
Ask from server obtain data and give function built-in variable d21, function built-in variable d22 ..., business 2 is in response to function
The changes of function built-in variable such as built-in variable d21, function built-in variable d22 and be performed, by that analogy.As shown in figure 4, thing
Part directly triggers business, in the case of multi-event trigger is multiple services, causes control logic complicated and is difficult to safeguard.
Especially, if the data of two service needed are closely similar, if being not desired to waste multiple AJAX request, often
Two business are mediated in same call back function, as shown in figure 5, business close-coupled each other, often leads to reconstruct, enter one
Step increased the difficulty of Row control.
Fig. 6 shows the Row control schematic diagram loaded according to the JS page of the disclosure.As shown in fig. 6, send AJAX please
Ask from server obtain data and give global variable 1, global variable 2, global variable 3 ..., each SM service monitoring and itself
The related global variable of trigger event, and be triggered in response to the change of monitored global variable.As shown in fig. 6, complete
Used as the interval between event and business, event triggers business to office's variable indirectly, being capable of abbreviation and decoupling Row control.Additionally, per
Individual global variable can be avoided, by multiple SM service monitorings, the AJAX request for initiating to repeat.
This sentences as a example by certain plays the page and illustrates.
The broadcast page face includes following global variable:
List of videos (videoList);
Comment (comment);
Video frequency searching (viewsearch);
Advertisement part is divided into 3 bulks:Advertisement 1 (ad1), advertisement 2 (ad2) and advertisement 3 (ad3), can be loaded respectively, its
In, advertisement 2 does not represent when advertisement 1 occurs;
Index ranking list (Statrank);
Interactive (Active), it is the data for being based on " interaction ", " list of videos " and " comment " which is presented.
Above-mentioned global variable can be encapsulated in the variable of entitled PlayerPage." afterwards load " herein and hereinafter
" non-core " be all for the purpose for playing the page plays the core content that this override of content is loaded.
As follows according to the false code of the post-loaded module for realizing the page of the disclosure:
Fig. 7 shows according to the page of above-mentioned false code and loads schematic diagram.According to this example, AJAX only focuses on data and removes
Fortune.Once completing the partial data filling in PlayerPage using AJAX request, the change of monitored data can be by certainly
Dynamic discovery, loads behavior so as to trigger the page, and the non-core module for realizing the page is loaded.Now, business is no longer dependent on ajax
Request, and depend directly on the value of each variable.
In this example, in the case of one-to-one control, such as " list of videos " module, when the data of list of videos module
(videoList) be acquired by ajax and assignment, then function can be monitored by which and listen to, list of videos mould be loaded so as to trigger
The business of block (dovideoList ()).
In this example, in the case of many-one control, the data of such as " interaction " module are to be based on " interaction "
(Active), the data of " list of videos " (videoList) and " comment " (comment), the monitoring function of its business can be monitored
" interaction " (Active), the data of " list of videos " (videoList) and " comment " (comment) three part, when three parts
Data all reach, triggering load interactive module business.
The real-time update application of data
There is a class application on the page, need real time polling interface that data are obtained, such as payment interface will be constantly to backstage
The whether success of inquiry current order, barrage application will constantly backward chaptrel ask barrage data of next time period etc..These
Business often has the polling conditions of complexity, and in traditional JS Row control, together with business is often interted with polling conditions, difficult
To safeguard.
The false code of barrage business in traditional JS Row control is presented herein below:
Pseudo-code example according to the barrage business of the disclosure can be:
Fig. 8 shows the Row control schematic diagram of the barrage business according to the disclosure with reference to above-mentioned false code.As Fig. 8 institute
Show, on the one hand, AJAX is absorbed in acquisition latest data and gives global variable, while judge whether to need to continue poll, no longer
Process the service logic after successfully obtaining data;And once the change of global variable is monitored arrives, then triggering call back function is executed
Corresponding service.Even if certain AJAX request will trigger more new business, without checking other industry related to the AJAX request
Business, only need to bind the call back function for executing the new business on the global variable carried by the AJAX request.
Additionally, when the real time business for having several based on AJAX poll in the page, such as barrage, watching record of user
Deng can only using one or less poll, without being taken turns using independent AJAX for each real time business according to the disclosure
Ask.Fig. 9 shows the multiple services Row control schematic diagram in traditional JS based on AJAX poll, it can be seen that see for user
Record traffic and barrage business is seen, respectively uses an AJAX poll;Figure 10 is shown according to the disclosure based on AJAX poll
Multiple services Row control schematic diagram, it can be seen that for watching record of user business and barrage business, only using an AJAX
Poll.This is conducive to saving internal memory.
Those of ordinary skill in the art are it is to be appreciated that each exemplary cell in embodiment described herein and algorithm
Step, being capable of being implemented in combination in electronic hardware or computer software and electronic hardware.These functions actually with hardware also
It is software form realizing, the application-specific depending on technical scheme and design constraint.Professional and technical personnel can be directed to
Specific application selects different methods to realize described function, but this realizes the model it is not considered that beyond the disclosure
Enclose.
If realized using in the form of computer software the function and as independent production marketing or use when,
To a certain extent it is believed that all or part (part for for example prior art being contributed) of the technical scheme of the disclosure is
Embody in form of a computer software product.The computer software product is generally stored inside the non-volatile of embodied on computer readable
In storage medium, use so that computer equipment (can be that personal computer, server or network set including some instructions
Standby etc.) execute all or part of step of each embodiment method of the disclosure.And aforesaid storage medium include USB flash disk, portable hard drive,
Read-only storage (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic
Dish or CD etc. are various can be with the medium of store program codes.
The above, the only specific embodiment of the disclosure, but the protection domain of the disclosure is not limited thereto, and any
Those familiar with the art can readily occur in change or replacement in the technical scope that the disclosure is disclosed, and should all contain
Cover within the protection domain of the disclosure.Therefore, the protection domain of the disclosure should be defined by the scope of the claims.
Claims (12)
1. a kind of flow control method for being applied to JavaScript, the method include:
AJAX request is initiated, is obtained data and one or more global variables is given, wherein, one or more of global variables
Be according to set by the trigger event of at least one business;
For each business at least one business, the global change according to set by the trigger event of the business is monitored
Amount, and when the global variable set by the trigger event according to the business changes, trigger the execution of the business.
2. the flow control method for being applied to JavaScript according to claim 1, wherein, described monitors according to the industry
Global variable set by the trigger event of business includes:
In the case that prototype function Object.defineProperty supported by browser, adopt
Object.defineProperty monitors the global variable according to set by the trigger event of the business.
3. the flow control method for being applied to JavaScript according to claim 2, wherein, the employing
Object.defineProperty monitors the global variable according to set by the trigger event of the business to be included:
For basic data type, directly by the get method in prototype function Object.defineProperty and set side
Method is monitored.
4. the flow control method for being applied to JavaScript according to claim 2, wherein, the employing
Object.defineProperty monitors the global variable according to set by the trigger event of the business to be included:
For the ARRAY type on the basis in data splitting type, by prototype function Object.defineProperty
Value method is monitored, also, calls the prototype letter for changing ARRAY data type data value in value method
Number.
5. according to the flow control method for being applied to JavaScript described in claim 2, wherein, the employing
Object.defineProperty monitors the global variable according to set by the trigger event of the business to be included:
For the JSON type in data splitting type and the ARRAY type of non-basic, its step-by-step recursion is decomposed until all
Element be basic data type or data splitting type in basis ARRAY type, and in all elements
Partly or entirely monitored;
Wherein, for basic data type, directly by the get method in prototype function Object.defineProperty and
Set method is monitored;For the ARRAY type on the basis in data splitting type, by prototype function
Value method in Object.defineProperty is monitored, and wherein, is called for changing in value method
The prototype function of ARRAY data type data value.
6. the flow control method for being applied to JavaScript according to claim 1, wherein, described monitors according to the industry
Global variable set by the trigger event of business includes:
In the case that browser does not support prototype function Object.defineProperty, automatic regular polling is according to the business
Global variable set by trigger event is to be monitored.
7. a kind of flow control device for being applied to JavaScript, the device include:
Global variable assignment unit, is configured to initiate AJAX request, obtains data and gives one or more global variables, its
In, one or more of global variables be according to set by the trigger event of at least one business;
Trigger element is monitored, is configured to, for each business at least one business, monitor touching according to the business
Global variable set by the event of sending out, and when the global variable set by the trigger event according to the business changes,
Trigger the execution of the business.
8. the flow control device for being applied to JavaScript according to claim 7, wherein, the monitoring trigger element
Also include the first monitoring subelement,
The first monitoring subelement is configured to support the situation of prototype function Object.defineProperty in browser
Under, the global variable according to set by the trigger event of the business is monitored using Object.defineProperty.
9. the flow control device for being applied to JavaScript according to claim 8, wherein, described first to monitor son single
Unit is configured to:
For basic data type, directly by the get method in prototype function Object.defineProperty and set side
Method is monitored.
10. the flow control device for being applied to JavaScript according to claim 8, wherein, described first monitors son
Unit is configured to:
For the ARRAY type on the basis in data splitting type, by prototype function Object.defineProperty
Value method is monitored, also, calls the prototype letter for changing ARRAY data type data value in value method
Number.
11. flow control devices for being applied to JavaScript according to claim 8, wherein, described first monitors son
Unit is configured to:
For the JSON type in data splitting type and the ARRAY type of non-basic, all units are decomposed to by step-by-step recursion
Element be basic data type or data splitting type in basis ARRAY type, and to the portion in all elements
Divide or all monitored,
Wherein, for basic data type, directly by the get method in prototype function Object.defineProperty and
Set method is monitored;For the ARRAY type on the basis in data splitting type, by prototype function
Value method in Object.defineProperty is monitored, and wherein, is called for changing in value method
The prototype function of ARRAY data type data value.
12. flow control devices for being applied to JavaScript according to claim 7, wherein, described monitoring triggers list
Unit also includes the second monitoring subelement,
Second monitoring subelement is configured to not support the situation of prototype function Object.defineProperty in browser
Under, global variable of the automatic regular polling according to set by the trigger event of the business is to be monitored.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610819490.7A CN106484459B (en) | 2016-09-12 | 2016-09-12 | Flow control method and device applied to JavaScript |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610819490.7A CN106484459B (en) | 2016-09-12 | 2016-09-12 | Flow control method and device applied to JavaScript |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106484459A true CN106484459A (en) | 2017-03-08 |
CN106484459B CN106484459B (en) | 2019-12-31 |
Family
ID=58273470
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610819490.7A Expired - Fee Related CN106484459B (en) | 2016-09-12 | 2016-09-12 | Flow control method and device applied to JavaScript |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106484459B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107678737A (en) * | 2017-10-12 | 2018-02-09 | 深圳怡化电脑股份有限公司 | Method for processing business, device and self-help terminal equipment |
CN109086150A (en) * | 2018-09-20 | 2018-12-25 | 杭州安恒信息技术股份有限公司 | A kind of method, apparatus for avoiding multiple asynchronous methods from repeating and electronic equipment |
CN110874380A (en) * | 2018-08-14 | 2020-03-10 | 山东华软金盾软件股份有限公司 | Method and system for refreshing interface based on mobile terminal database |
CN113268223A (en) * | 2021-07-20 | 2021-08-17 | 广州市玄武无线科技股份有限公司 | Responsive object creating method, system, medium and building method of framework thereof |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109711809B (en) * | 2018-12-28 | 2021-07-30 | 广东益萃网络科技有限公司 | Merchant attribute setting method and device, computer equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20060224561A1 (en) * | 2005-03-30 | 2006-10-05 | International Business Machines Corporation | Method and apparatus for associating logical conditions with the re-use of a database query execution strategy |
CN101296255A (en) * | 2008-06-30 | 2008-10-29 | 腾讯科技(深圳)有限公司 | Web page browsing method, system, proxy server and mobile phone browser |
CN103179151A (en) * | 2011-12-21 | 2013-06-26 | 上海博路信息技术有限公司 | Internet surfing method based on cloud model |
CN105159669A (en) * | 2015-08-13 | 2015-12-16 | 浪潮(北京)电子信息产业有限公司 | Method and system for orderly processing multiple Ajax data sources |
-
2016
- 2016-09-12 CN CN201610819490.7A patent/CN106484459B/en not_active Expired - Fee Related
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20060224561A1 (en) * | 2005-03-30 | 2006-10-05 | International Business Machines Corporation | Method and apparatus for associating logical conditions with the re-use of a database query execution strategy |
CN101296255A (en) * | 2008-06-30 | 2008-10-29 | 腾讯科技(深圳)有限公司 | Web page browsing method, system, proxy server and mobile phone browser |
CN103179151A (en) * | 2011-12-21 | 2013-06-26 | 上海博路信息技术有限公司 | Internet surfing method based on cloud model |
CN105159669A (en) * | 2015-08-13 | 2015-12-16 | 浪潮(北京)电子信息产业有限公司 | Method and system for orderly processing multiple Ajax data sources |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107678737A (en) * | 2017-10-12 | 2018-02-09 | 深圳怡化电脑股份有限公司 | Method for processing business, device and self-help terminal equipment |
CN107678737B (en) * | 2017-10-12 | 2021-01-01 | 深圳怡化电脑股份有限公司 | Service processing method and device and self-service terminal equipment |
CN110874380A (en) * | 2018-08-14 | 2020-03-10 | 山东华软金盾软件股份有限公司 | Method and system for refreshing interface based on mobile terminal database |
CN109086150A (en) * | 2018-09-20 | 2018-12-25 | 杭州安恒信息技术股份有限公司 | A kind of method, apparatus for avoiding multiple asynchronous methods from repeating and electronic equipment |
CN113268223A (en) * | 2021-07-20 | 2021-08-17 | 广州市玄武无线科技股份有限公司 | Responsive object creating method, system, medium and building method of framework thereof |
Also Published As
Publication number | Publication date |
---|---|
CN106484459B (en) | 2019-12-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106484459A (en) | It is applied to flow control method and the device of JavaScript | |
CN103810020B (en) | Virtual machine elastic telescopic method and device | |
CN106951926A (en) | The deep learning systems approach and device of a kind of mixed architecture | |
US20140365198A1 (en) | Techniques to simulate production events | |
Mei et al. | An adaptive service selection approach to service composition | |
CN108595316A (en) | Life cycle management method, manager, equipment and the medium of Distributed Application | |
CN104935660B (en) | A kind of cloud program development operating system, method and device | |
CN108052589A (en) | The method, apparatus and storage medium of a kind of text exhibition | |
CN108108248A (en) | A kind of CPU+GPU cluster management methods, device and equipment for realizing target detection | |
CN107944000A (en) | Flight freight rate update method, device, electronic equipment, storage medium | |
CN107329991A (en) | A kind of list access to web page and methods of exhibiting and its system | |
CN106411639A (en) | Method and system for monitoring access data | |
CN109558310A (en) | Method for generating test case and device | |
CN112559301A (en) | Service processing method, storage medium, processor and electronic device | |
CN110177146A (en) | A kind of non-obstruction Restful communication means, device and equipment based on asynchronous event driven | |
CN114584829B (en) | Method and system for managing list active page | |
WO2019000895A1 (en) | Method and system for managing anomaly log of flash player | |
CN104731564A (en) | Generation method and device for system interface call records | |
CN107908481A (en) | A kind of method of data synchronization, device and system | |
CN110837511A (en) | Data processing method, system and related equipment | |
CN107479870A (en) | A kind of third party's class libraries call method, device, mobile terminal and storage medium | |
CN110188258B (en) | Method and device for acquiring external data by using crawler | |
CN116009985A (en) | Interface calling method, device, computer equipment and storage medium | |
CN115563160A (en) | Data processing method, data processing device, computer equipment and computer readable storage medium | |
CN108628884A (en) | A kind of Complex event processing method, system and its apparatus |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | 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 | ||
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20200521 Address after: 310052 room 508, floor 5, building 4, No. 699, Wangshang Road, Changhe street, Binjiang District, Hangzhou City, Zhejiang Province Patentee after: Alibaba (China) Co.,Ltd. Address before: 518030, Sannuo building, 19L02, 3012 Binhai Avenue, Shenzhen, Guangdong, Nanshan District Patentee before: HEYI INTELLIGENT TECHNOLOGY (SHENZHEN) Co.,Ltd. |
|
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20191231 Termination date: 20200912 |