UniApp applets REQUEST preloading tools
This is the first time to release this kind of thing, due to work reasons, there is not a lot of testing time, if there is a problem, please show mercy, you can also contact me directly vX, VX: B948993029
Yards cloud address
Note: It is best to set a timeout time for preloading HTTP requests. If there is no timeout time, preloading will always be in progress and cannot be handled for timeout or error conditions
- I just think, in the development of uniApp why wait until after the onLoad each page request to the requested page, clearly know which page to enter, and need the data, why not ready before entering the request of the loading, thus avoiding the enter the page to wait for the return and render a page of data Even though the jump animation is only 300ms, if the response stays within 300ms, it’s silky smooth and I don’t think anyone will say no.
Example sample
addHttp(id, func, params)
runAddHttp(id, func, params)
removeHttp(id)
getData(id, func)
send(id, params, isDelete)
methods | parameter | instructions |
---|---|---|
addHttp | @param {string} ID Unique preloading ID Default: mandatory @param {PROMISE} Func preloading method PROMISE type Default: mandatory @param {object} Params Preloading method parameter Default: null | The latter overrides the former when the preloaded request function repeats the ID |
runAddHttp | @param {string} ID Unique preloading ID @param {PROMISE} func Preloading method PROMISE Type Default: mandatory @param {object} Params preloading method parameter Default: null | The latter overrides the former when the preload request function repeats the ID adding and executing immediately |
removeHttp | @param {string} id Unique preload ID Default: Mandatory | Delete the preload request function |
getData | @param {string} id Unique preload ID Default: Mandatory | Get the preload result |
send | @param {string} id Unique preloading ID Default: mandatory @param {object} params Preloading method parameters Can be changed before request parameters Default: Null @param {Boolean} isDelete Whether to delete the preloading method By default, the preloading method is not deleted | Perform preloading |