mnl
miniprogram-network-life-circle
npm i miniprogram-network-life-circle
mnl

miniprogram-network-life-circle

* [x] Promise * [x] Cancelable * [x] Interceptors in Lifecycle (only one,modify data or status) * [x] transform request data * [x] transform response data * [x] Global Listeners * [x] On Send (before request data send & after request dat

by New Future

1.4.0-alpha.0 (see all)License:Apache-2.0TypeScript:Built-In
npm i miniprogram-network-life-circle
Readme

miniprogram-network-life-circle npm version

网络请求生命周期

  • Promise
  • Cancelable
  • Interceptors in Lifecycle (only one,modify data or status)
    • transform request data
    • transform response data
  • Global Listeners
    • On Send (before request data send & after request data transformed)
    • On Response (after request response data transformed)
    • On resolved? (before then of Promise)
    • On rejected (before catch of Promise)
    • On abort
    • On complete

API

  • Request.Defaults 全局配置项目
    • transformSend(options: Exclude<FullOptions, 'transformSend' | 'transformResponse'>) => wx.Options | Promise<wx.Options> 发送前转换参数
    • transformResponse(res: wx.SuccessCallbackResult, config: TFullOptions) => any | Promise<any> 数据返回转换参数
  • Reqeust.Listeners 全局事件监听列表
    • [onSend(options: RequestOptions) => any]; 发送前事件监听列表
    • [onResponse(res: wx.RequestSuccessCallbackResult, options: RequestOptions) => any]; 收到服务器响应事件监听列表
    • [onComplete(res: wx.GeneralCallbackResult, options: RequestOptions) => any];每个操作完成事件响应
    • [onReject(res: any | wx.GeneralCallbackResult, options: RequestOptions) => any];操作最终失败响应事件
    • [onAbort(reason: any, options: RequestOptions) => any];取消操作响应事件

LifeCircle

Request Life Circle

Downloads/wk

38

GitHub Stars

0
No data available

LAST COMMIT

NaNyrs ago

MAINTAINERS

1

CONTRIBUTORS

0

OPEN ISSUES

0

OPEN PRs

0
No data available
VersionTagPublished
1.4.0-alpha.0
latest
3yrs ago
No alternatives found
No tutorials found
Add a tutorial