CN111222014A - Request processing method and device, electronic equipment and storage medium - Google Patents

Request processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111222014A
CN111222014A CN201911426300.5A CN201911426300A CN111222014A CN 111222014 A CN111222014 A CN 111222014A CN 201911426300 A CN201911426300 A CN 201911426300A CN 111222014 A CN111222014 A CN 111222014A
Authority
CN
China
Prior art keywords
request
component
function
identification information
asynchronous
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
Application number
CN201911426300.5A
Other languages
Chinese (zh)
Other versions
CN111222014B (en
Inventor
李春强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Reach Best Technology Co Ltd
Original Assignee
Reach Best Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Reach Best Technology Co Ltd filed Critical Reach Best Technology Co Ltd
Priority to CN201911426300.5A priority Critical patent/CN111222014B/en
Publication of CN111222014A publication Critical patent/CN111222014A/en
Application granted granted Critical
Publication of CN111222014B publication Critical patent/CN111222014B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/80Information retrieval; Database structures therefor; File system structures therefor of semi-structured data, e.g. markup language structured data such as SGML, XML or HTML
    • G06F16/83Querying
    • G06F16/835Query processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services

Abstract

The disclosure shows a request processing method, a device, an electronic device and a storage medium, when an assembly sends an asynchronous request, obtaining identification information of the asynchronous request sent by the assembly; when the component is detected to start the component destroying process, the identification information of the asynchronous request is transmitted to the request destroying function, so that the request destroying function terminates the asynchronous request according to the identification information. According to the technical scheme, when the component is destroyed, the identification information of the asynchronous request sent by the component is transmitted to the request destruction function, so that the asynchronous request corresponding to the identification information is automatically cancelled by the request destruction function, network resources of a user are saved, the problem of abort request does not need to be considered when the component is destroyed, and user experience can be improved.

Description

Request processing method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a request processing method and apparatus, an electronic device, and a storage medium.
Background
With the development of front-end technology, MVVM development modes represented by three frameworks of Angular, fact and Vue gradually become mainstream. Compared with the traditional command type development mode, the MVVM declarative programming mode frees a developer from a complex interaction mode, and therefore only data change needs to be concerned.
When developed using vue, it is often necessary to asynchronously obtain data for rendering through asynchronous JavaScript and XML requests. vue component has eight lifecycle, which is before update, created, before count, mounted, before update, updated, before delete, and deleted. In the process of rendering the component, there may be a case that the asynchronous request is not completed and the component is destroyed. For example, the user may return soon after entering a page, when the request is effectively invalid because the data requested back is not used. While neither the browser nor the vue framework deal specifically with this situation, the requests that are still in progress are wasteful of the user's network resources.
Disclosure of Invention
The present disclosure provides a request processing method, device, electronic device and storage medium, so as to at least solve the problem in the related art that a network resource is wasted by a request still in progress after a component is destroyed. The technical scheme of the disclosure is as follows:
according to a first aspect of the present disclosure, there is provided a request processing method, the method comprising:
when an assembly sends an asynchronous request, acquiring identification information of the asynchronous request sent by the assembly;
and when the component is detected to start the component destroying process, transmitting the identification information of the asynchronous request to a request destroying function so that the request destroying function terminates the asynchronous request according to the identification information.
In an optional implementation manner, the step of passing the identification information of the asynchronous request to a request destruction function when it is detected that the component starts a component destruction process includes:
and when the component is detected to call the life cycle function corresponding to the component, transmitting the identification information to the function of requesting to destroy.
In an optional implementation manner, the step of passing the identification information of the asynchronous request to a request destruction function includes:
calling the function of destroying the request in a database;
and transmitting the identification information to the request destruction function.
In an alternative implementation, the step of sending an asynchronous request by the component includes:
defining a decorator function and a decorated function, wherein the decorated function comprises a class function corresponding to the component;
and calling asynchronous JavaScript and XML methods in the decorated function to send the asynchronous request through an axios library.
In an optional implementation manner, the step of obtaining the identification information of the asynchronous request sent by the component includes:
establishing a first variable in the decorator function, and storing the identification information in the first variable, wherein the first variable is a source variable, and the identification information is Token;
when the asynchronous request is sent by adopting the asynchronous JavaScript and XML method, the cancel token is configured as source by default, and the identification information corresponding to the asynchronous request is obtained.
According to a second aspect of the present disclosure, there is provided a request processing apparatus, the apparatus comprising:
a first module configured to acquire identification information of an asynchronous request sent by a component when the component sends the asynchronous request;
a second module configured to, when detecting that the component starts a component destruction process, transfer identification information of the asynchronous request to a request destruction function, so that the request destruction function terminates the asynchronous request according to the identification information.
In an alternative implementation, the second module is specifically configured to:
and when the component is detected to call the life cycle function corresponding to the component, transmitting the identification information to the function of requesting to destroy.
In an alternative implementation, the second module is specifically configured to:
calling the function of destroying the request in a database;
and transmitting the identification information to the request destruction function.
In an optional implementation, the first module is specifically configured to:
defining a decorator function and a decorated function, wherein the decorated function comprises a class function corresponding to the component;
and calling asynchronous JavaScript and XML methods in the decorated function to send the asynchronous request through an axios library.
In an optional implementation, the first module is specifically configured to:
establishing a first variable in the decorator function, and storing the identification information in the first variable, wherein the first variable is a source variable, and the identification information is Token;
when the asynchronous request is sent by adopting the asynchronous JavaScript and XML method, the cancel token is configured as source by default, and the identification information corresponding to the asynchronous request is obtained.
According to a third aspect of the present disclosure, there is provided an electronic apparatus comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the request processing method of the first aspect.
According to a fourth aspect of the present disclosure, there is provided a storage medium having instructions that, when executed by a processor of an electronic device, enable the electronic device to perform the request processing method according to the first aspect.
According to a fifth aspect of the present disclosure, there is provided a computer program product, wherein instructions, when executed by a processor of an electronic device, enable the electronic device to perform the request processing method of the first aspect.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
the technical scheme of the disclosure provides a request processing method, a request processing device, electronic equipment and a storage medium, wherein when an assembly sends an asynchronous request, identification information of the asynchronous request sent by the assembly is obtained; when the component is detected to start the component destroying process, the identification information of the asynchronous request is transmitted to the request destroying function, so that the request destroying function terminates the asynchronous request according to the identification information. According to the technical scheme, when the component is destroyed, the identification information of the asynchronous request sent by the component is transmitted to the request destruction function, so that the asynchronous request corresponding to the identification information is automatically cancelled by the request destruction function, network resources of a user are saved, the problem of abort request does not need to be considered when the component is destroyed, and user experience can be improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
FIG. 1 is a flow diagram illustrating a request processing method in accordance with an exemplary embodiment.
FIG. 2 is a flow diagram illustrating the sending of an asynchronous request in accordance with an illustrative embodiment.
Fig. 3 is a flowchart illustrating a specific implementation of a request processing method according to an example embodiment.
FIG. 4 is a block diagram illustrating a request processing device in accordance with an exemplary embodiment.
FIG. 5 is a block diagram illustrating an electronic device in accordance with an example embodiment.
FIG. 6 is a block diagram illustrating an electronic device in accordance with an example embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
FIG. 1 is a flow diagram illustrating a request processing method according to an example embodiment, which may include the following steps, as shown in FIG. 1.
In step S11, when the component transmits an asynchronous request, identification information of the asynchronous request transmitted by the component is acquired.
The component may be, for example, an vue component. The implementation manner of sending the asynchronous request by the component is various, for example, the component can be expanded by using mixins provided in vue, and an asynchronous JavaScript and XML request method is injected to provide the component with the capability of sending the asynchronous request; the component can be further expanded through a decorator function and a decorator function, an asynchronous request is sent by calling an asynchronous JavaScript and XML method in the decorated function, and the specific implementation mode of sending the asynchronous request by the component is described in detail in the subsequent embodiment.
In the process of destroying or interrupting the asynchronous request, the destroy object may be determined by the identification information, so that the identification information corresponding to the asynchronous request sent by the component needs to be acquired. The specific acquisition mode corresponds to the mode in which the component sends an asynchronous request, which will be illustrated in the following embodiments.
In step S12, when it is detected that the component starts the component destruction process, the identification information of the asynchronous request is passed to the request destruction function, so that the request destruction function terminates the asynchronous request according to the identification information.
In a specific implementation, when the destruction of the component is detected, the identification information is called by the request destruction function, and the asynchronous request corresponding to the identification information is automatically destroyed, so that the asynchronous request which is still in progress and consumes network resources is destroyed when the component is destroyed.
In an alternative implementation, when it is detected that the component calls a lifecycle function corresponding to the component, it is determined that the component is detected to start a component destruction process. When detecting that the component starts the component destroying process, firstly calling a function for requesting to destroy in a database; and then the identification information is transmitted to a request destruction function, so that the identification information of the asynchronous request is transmitted to the request destruction function. The specific implementation process will be exemplified in the following embodiments.
In the request processing method provided by this embodiment, when the component is destroyed, the identification information of the asynchronous request sent by the component is transferred to the request destruction function, and the asynchronous request corresponding to the identification information is automatically cancelled by the request destruction function, so that network resources of a user are saved.
In an alternative implementation manner, referring to fig. 2, step S11 may specifically include:
in step S21, a decorator function and a decorated function are defined, the decorated function including a class function corresponding to the component.
The decorator function can be used for processing other functions, the additional functions can be added to the other functions on the premise that no code change is needed, and the return value of the decorator function can also be a function object.
In a specific implementation, a decorator function can be defined as a with ajax (asynchronous JavaScript and XML) function, the function receives a constructor as an input parameter, the constructor is a class function corresponding to a component, and is equivalent to a decorated function, and the with ajax provides various methods for the class function.
In step S22, the asynchronous JavaScript and XML method in the decorated function is called by the axios library to send an asynchronous request.
Since the component itself does not support asynchronous request sending, sending of asynchronous requests can be achieved through vue-resource, axios, etc. library functions. When the component is a class-style vue component, the request library may be axios.
In a specific implementation, an ajax (asynchronous JavaScript and XML) method may be newly added to an original prototypetype of a constructor (or class function) constractor, an axios library is encapsulated, and an ability of sending an asynchronous request is provided for a component, and at this time, the component may directly use this. This step provides the capability for the component to send asynchronous requests by injecting asynchronous JavaScript and XML methods for the component.
Axios is an excellent premium http library based on premium, which is used to send requests, and can be used in browsers and node. Using axios in the vue component, axios can be packaged into separate files separately, the addition interceptor performs unified processing on asynchronous requests, such as unified error processing, token addition in the request header, data format processing, etc., and then derives the corresponding axios instance. When used in traffic code, axios instances can be mounted on the prototype chain vue. Or directly import axios instance in vue component, send asynchronous request.
Accordingly, in this implementation manner, the step of obtaining the identification information of the asynchronous request sent by the component may include:
in step S23, a first variable is established in the decorator function, and identification information is stored in the first variable, where the first variable is a source variable and the identification information is Token;
in step S24, when the asynchronous request is sent by using the asynchronous JavaScript and XML method, the cancel token is configured as source.
Because the identification information cancel token api is needed when the http request (asynchronous request) is interrupted in the axios library, a source variable (first variable) can be newly built in the decorator function with ajax, and the value of the first variable is set to axios. This step preserves the identification information by injecting a first variable into the component.
Further, when the asynchronous request is sent by using an asynchronous JavaScript and XML method, a default configuration cancel token may be added to establish a relationship between the sent asynchronous request and the identification information, and obtain the identification information corresponding to the asynchronous request, so that a subsequent destroy function may determine the asynchronous request through the identification information and destroy the asynchronous request.
Accordingly, in this implementation manner, the step S12 may further include: rewriting a component before destruction (hook function) on a constructor prototype, saving an original component before rewriting, calling the original component before destruction function in a new component before rewriting function to ensure that normal logic of the component is not influenced, and triggering a request destruction function source. The method comprises the steps that an original component before destroy function is called, the component can be destroyed, the asynchronous request is cancelled after the component is destroyed, and the purpose that the asynchronous request is automatically cancelled by triggering the destroy function source.
Class (Class) style vue components are used in this implementation, and components are easily expanded by decorators when written vue using the Class style. Decorators are an experimental property in Javascript that can add labels to us on declarations and members of classes through meta-programming syntax. The decorator model is a design model that dynamically adds some responsibility or behavior to the object, enabling additional functionality to be added to the class without the object's own perception. The use of the decorator mode does not require each component to be rewritten, simplifies the development difficulty and is beneficial to later maintenance.
In another implementation, the components may also be extended by using the mixins provided in vue, and an asynchronous JavaScript and XML request method is injected to provide the components with the capability of sending asynchronous requests, so that when the components sending asynchronous requests are destroyed, the incomplete asynchronous requests are destroyed in time. mixins is a way of dispensing reusable functionality in components provided by the vue authority, with some invasiveness to the components. The concrete implementation process using mixins can firstly inject source into the data of the component to store cancel token, inject asynchronous JavaScript and XML methods into the methods of the component to provide the component with the capability of sending requests, and cancel the requests within the before hierarchy life cycle. Since the Mixins needs to rewrite each component, the request needs to be cancelled in the before development lifecycle of each component, which is too cumbersome, and a large number of components need to write similar codes, so that the development experience is not good, and the maintenance is not facilitated.
In practical applications, referring to fig. 3, the request processing method provided in this embodiment may be implemented by the following steps:
1. realizing a with ajax function, wherein the function receives a constructor as a parameter; wherein ajax is asynchronous JavaScript and XML;
2. interrupting an http request in an axios library needs to use a cancel token API, so that a source variable needs to be newly built in withajax, and the variable value is axios. The purpose of this step is to give the injection source of the assembly to save the cancel token;
3. adding an ajax method on an prototype of a constractor, encapsulating axios, and providing an ajax request sending capability for a component, wherein the component at the moment can directly use this.ajax (url) to send a request, and meanwhile, when the axios is used to send the request, adding a default configuration cancelltoken into source.token;
4. rewriting a component before-destroy function on a constractor prototype, saving the original component before rewriting, calling the original component before-destroy function in a new component before-destroy function to ensure that normal destroy logic of the component is not influenced, and calling a request function source.
This realizes a perfect decorator, after the decorator is used in the component, the request can be directly sent without introducing other http libraries, and the problem of abort request is not considered when the component is destroyed, so the embodiment solves the problem that the asynchronous request is not cancelled after the vue component is destroyed.
FIG. 4 is a block diagram illustrating a request processing device according to an example embodiment. Referring to fig. 4, the apparatus may include:
a first module 41 configured to, when a component sends an asynchronous request, acquire identification information of the asynchronous request sent by the component;
a second module 42, configured to, when detecting that the component starts a component destruction process, pass identification information of the asynchronous request to a request destruction function, so that the request destruction function terminates the asynchronous request according to the identification information.
The component may be, for example, an vue component. The implementation manner of sending the asynchronous request by the component is various, for example, the component can be expanded by using mixins provided in vue, and an asynchronous JavaScript and XML request method is injected to provide the component with the capability of sending the asynchronous request; the components can be expanded through a decorator function and a decorator function, and an asynchronous request is sent by calling an asynchronous JavaScript and XML method in the decorated function.
Since the destruction object may be determined by the identification information during the process of destroying or interrupting the asynchronous request, the first module 41 needs to acquire the identification information corresponding to the asynchronous request sent by the component.
In a specific implementation, when the component destruction is detected, the second module 42 may first call the identification information by the function for requesting destruction, and automatically destroy the asynchronous request corresponding to the identification information, so that when the component is destroyed, the asynchronous request that still consumes network resources and is still in progress is destroyed.
In an alternative implementation, when the second module 42 detects that the component calls a lifecycle function corresponding to the component, it is determined that the component is detected to initiate a component destruction process. When the second module 42 detects that the component starts the component destruction process, it may first call a destroy-request function in the database; and then the identification information is transmitted to a request destruction function, so that the identification information of the asynchronous request is transmitted to the request destruction function.
The request processing apparatus provided in this embodiment transfers, when the component is destroyed, the identification information of the asynchronous request sent by the component to the request destruction function, and automatically cancels the asynchronous request corresponding to the identification information through the request destruction function, so as to save network resources of a user.
In an alternative implementation, the second module 42 is specifically configured to:
and when the component is detected to call the life cycle function corresponding to the component, transmitting the identification information to the function of requesting to destroy.
In an alternative implementation, the second module 42 is specifically configured to:
calling the function of destroying the request in a database;
and transmitting the identification information to the request destruction function.
In an alternative implementation, the first module 41 is specifically configured to:
defining a decorator function and a decorated function, wherein the decorated function comprises a class function corresponding to the component;
and calling asynchronous JavaScript and XML methods in the decorated function to send the asynchronous request through an axios library.
In an alternative implementation, the first module 41 is specifically configured to:
establishing a first variable in the decorator function, and storing the identification information in the first variable, wherein the first variable is a source variable, and the identification information is Token;
when the asynchronous request is sent by adopting the asynchronous JavaScript and XML method, the cancel token is configured as source by default, and the identification information corresponding to the asynchronous request is obtained.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 5 is a block diagram of one type of electronic device 800 shown in the present disclosure. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 5, electronic device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input/output (I/O) interface 812, a sensor component 814, and a communication component 816.
The processing component 802 generally controls overall operation of the electronic device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the request processing method described in any embodiment. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operation at the device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices, such as Static Random Access Memory (SRAM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power supply component 806 provides power to the various components of the electronic device 800. The power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 800.
The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 800 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the electronic device 800. For example, the sensor assembly 814 may detect an open/closed state of the device 800, the relative positioning of components, such as a display and keypad of the electronic device 800, the sensor assembly 814 may also detect a change in the position of the electronic device 800 or a component of the electronic device 800, the presence or absence of user contact with the electronic device 800, orientation or acceleration/deceleration of the electronic device 800, and a change in the temperature of the electronic device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 may access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G, or 5G), or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the request processing methods described in any of the embodiments.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the electronic device 800 to perform the request processing method of any of the embodiments is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, a computer program product is also provided, which comprises readable program code executable by the processor 820 of the device 800 to perform the request handling method of any of the embodiments. Alternatively, the program code may be stored in a storage medium of the apparatus 800, which may be a non-transitory computer readable storage medium, for example, ROM, Random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, and the like.
Fig. 6 is a block diagram of one type of electronic device 1900 shown in the present disclosure. For example, the electronic device 1900 may be provided as a server.
Referring to fig. 6, electronic device 1900 includes a processing component 1922 further including one or more processors and memory resources, represented by memory 1932, for storing instructions, e.g., applications, executable by processing component 1922. The application programs stored in memory 1932 may include one or more modules that each correspond to a set of instructions. Further, the processing component 1922 is configured to execute instructions to perform the request processing method of any of the embodiments.
The electronic device 1900 may also include a power component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input/output (I/O) interface 1958. The electronic device 1900 may operate based on an operating system, such as Windows Server, MacOSXTM, UnixTM, LinuxTM, FreeBSDTM, or the like, stored in memory 1932.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
A1, a request processing method, the method comprising:
when an assembly sends an asynchronous request, acquiring identification information of the asynchronous request sent by the assembly;
and when the component is detected to start the component destroying process, transmitting the identification information of the asynchronous request to a request destroying function so that the request destroying function terminates the asynchronous request according to the identification information.
A2, according to the method in a1, the step of passing the identification information of the asynchronous request to a request destruction function when detecting that the component starts a component destruction process includes:
and when the component is detected to call the life cycle function corresponding to the component, transmitting the identification information to the function of requesting to destroy.
A3, according to the method of A1, the step of passing the identification information of the asynchronous request to a request destruction function includes:
calling the function of destroying the request in a database;
and transmitting the identification information to the request destruction function.
A4, the step of the component sending asynchronous requests according to the method of A1, comprising:
defining a decorator function and a decorated function, wherein the decorated function comprises a class function corresponding to the component;
and calling asynchronous JavaScript and XML methods in the decorated function to send the asynchronous request through an axios library.
A5, according to the method of A4, the step of obtaining the identification information of the asynchronous request sent by the component includes:
establishing a first variable in the decorator function, and storing the identification information in the first variable, wherein the first variable is a source variable, and the identification information is Token;
when the asynchronous request is sent by adopting the asynchronous JavaScript and XML method, the cancel token is configured as source by default, and the identification information corresponding to the asynchronous request is obtained.
A6, a request processing device, the device comprising:
a first module configured to acquire identification information of an asynchronous request sent by a component when the component sends the asynchronous request;
a second module configured to, when detecting that the component starts a component destruction process, transfer identification information of the asynchronous request to a request destruction function, so that the request destruction function terminates the asynchronous request according to the identification information.
A7, the apparatus of A6, the second module specifically configured to:
and when the component is detected to call the life cycle function corresponding to the component, transmitting the identification information to the function of requesting to destroy.
A8, the apparatus of A6, the second module specifically configured to:
calling the function of destroying the request in a database;
and transmitting the identification information to the request destruction function.
A9, the apparatus of A6, the first module specifically configured to:
defining a decorator function and a decorated function, wherein the decorated function comprises a class function corresponding to the component;
and calling asynchronous JavaScript and XML methods in the decorated function to send the asynchronous request through an axios library.
A10, the apparatus of A9, the first module specifically configured to:
establishing a first variable in the decorator function, and storing the identification information in the first variable, wherein the first variable is a source variable, and the identification information is Token;
when the asynchronous request is sent by adopting the asynchronous JavaScript and XML method, the cancel token is configured as source by default, and the identification information corresponding to the asynchronous request is obtained.

Claims (10)

1. A method for processing a request, the method comprising:
when an assembly sends an asynchronous request, acquiring identification information of the asynchronous request sent by the assembly;
and when the component is detected to start the component destroying process, transmitting the identification information of the asynchronous request to a request destroying function so that the request destroying function terminates the asynchronous request according to the identification information.
2. The method according to claim 1, wherein the step of passing the identification information of the asynchronous request to a request destruction function upon detecting that the component initiates a component destruction process comprises:
and when the component is detected to call the life cycle function corresponding to the component, transmitting the identification information to the function of requesting to destroy.
3. The method of claim 1, wherein the step of passing the identification information of the asynchronous request to a request destruction function comprises:
calling the function of destroying the request in a database;
and transmitting the identification information to the request destruction function.
4. The method of claim 1, wherein the step of the component sending an asynchronous request comprises:
defining a decorator function and a decorated function, wherein the decorated function comprises a class function corresponding to the component;
and calling asynchronous JavaScript and XML methods in the decorated function to send the asynchronous request through an axios library.
5. The method of claim 4, wherein the step of obtaining the identification information of the asynchronous request sent by the component comprises:
establishing a first variable in the decorator function, and storing the identification information in the first variable, wherein the first variable is a source variable, and the identification information is Token;
when the asynchronous request is sent by adopting the asynchronous JavaScript and XML method, the cancel token is configured as source by default, and the identification information corresponding to the asynchronous request is obtained.
6. A request processing apparatus, characterized in that the apparatus comprises:
a first module configured to acquire identification information of an asynchronous request sent by a component when the component sends the asynchronous request;
a second module configured to, when detecting that the component starts a component destruction process, transfer identification information of the asynchronous request to a request destruction function, so that the request destruction function terminates the asynchronous request according to the identification information.
7. The apparatus of claim 6, wherein the second module is specifically configured to:
and when the component is detected to call the life cycle function corresponding to the component, transmitting the identification information to the function of requesting to destroy.
8. The apparatus of claim 6, wherein the second module is specifically configured to:
calling the function of destroying the request in a database;
and transmitting the identification information to the request destruction function.
9. An electronic device, characterized in that the electronic device comprises:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the request processing method of any of claims 1 to 5.
10. A storage medium in which instructions, when executed by a processor of an electronic device, enable the electronic device to perform the request processing method of any one of claims 1 to 5.
CN201911426300.5A 2019-12-30 2019-12-30 Request processing method, request processing device, electronic equipment and storage medium Active CN111222014B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911426300.5A CN111222014B (en) 2019-12-30 2019-12-30 Request processing method, request processing device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911426300.5A CN111222014B (en) 2019-12-30 2019-12-30 Request processing method, request processing device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111222014A true CN111222014A (en) 2020-06-02
CN111222014B CN111222014B (en) 2024-03-26

Family

ID=70810760

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911426300.5A Active CN111222014B (en) 2019-12-30 2019-12-30 Request processing method, request processing device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111222014B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112559614A (en) * 2020-12-17 2021-03-26 济南浪潮数据技术有限公司 Database access method, OpenStack cloud platform and medium
CN112905160A (en) * 2021-02-08 2021-06-04 中国工商银行股份有限公司 Axios-based package registration global interception method and device
CN114610511A (en) * 2022-03-07 2022-06-10 北京百度网讯科技有限公司 Input verification method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100191708A1 (en) * 2009-01-23 2010-07-29 International Business Machines Corporation Synchronous Deletion of Managed Files
CN103561417A (en) * 2013-11-08 2014-02-05 五八同城信息技术有限公司 Method for improving response quality of mobile client products to user request
CN106022119A (en) * 2016-05-23 2016-10-12 北京金山安全软件有限公司 Window protection method and device and terminal
CN108399120A (en) * 2017-02-06 2018-08-14 腾讯科技(深圳)有限公司 asynchronous message monitoring method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100191708A1 (en) * 2009-01-23 2010-07-29 International Business Machines Corporation Synchronous Deletion of Managed Files
CN103561417A (en) * 2013-11-08 2014-02-05 五八同城信息技术有限公司 Method for improving response quality of mobile client products to user request
CN106022119A (en) * 2016-05-23 2016-10-12 北京金山安全软件有限公司 Window protection method and device and terminal
CN108399120A (en) * 2017-02-06 2018-08-14 腾讯科技(深圳)有限公司 asynchronous message monitoring method and device

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112559614A (en) * 2020-12-17 2021-03-26 济南浪潮数据技术有限公司 Database access method, OpenStack cloud platform and medium
CN112905160A (en) * 2021-02-08 2021-06-04 中国工商银行股份有限公司 Axios-based package registration global interception method and device
CN114610511A (en) * 2022-03-07 2022-06-10 北京百度网讯科技有限公司 Input verification method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN111222014B (en) 2024-03-26

Similar Documents

Publication Publication Date Title
WO2016041312A1 (en) Application program running method and device
CN111222014B (en) Request processing method, request processing device, electronic equipment and storage medium
CN107423106B (en) Method and apparatus for supporting multi-frame syntax
US9870239B2 (en) Method and device for running application program
CN109669730B (en) Process keep-alive method, device, electronic equipment and medium
CN105808305B (en) Static resource loading method and device
CN109582400B (en) Program calling method and device
CN107423218B (en) Application testing method, device and terminal
CN111427622B (en) Execution method and device of script codes in application program
CN107463372B (en) Data-driven page updating method and device
CN112433724A (en) Target component style generation method and device, electronic equipment and storage medium
CN111314419B (en) Network request method and device
CN110543265A (en) Page title bar generation method and device, electronic equipment and storage medium
CN112651012B (en) Information processing method and device
CN109032583B (en) Data interaction method and device
CN108958943B (en) Memory release method and device
CN111597106A (en) Point burying management method and device
CN112214252A (en) Information expansion method and device and electronic equipment
CN112083981A (en) Method and device for creating page view component
CN114531493B (en) Request processing method and device, electronic equipment and storage medium
CN115203618B (en) Page processing method and device, electronic equipment and storage medium
CN110795444B (en) DOM data updating method, page updating method and device
CN113360341B (en) Front-end application maintenance and loading method and device
CN111596949B (en) Method and device for developing application program
WO2023245374A1 (en) View display method and apparatus, electronic device, and storage medium

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