1.0.3 • Published 10 months ago

chunk-res v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

Chunk Res

Github

用于在微信小程序中实现 http 的流式响应, 无关框架, 在原生小程序UniAppTaro等都适用

安装

  1. pnpm add chunk-res

  2. 直接从Github下载chunkRes.(ts/js)到项目中即可

使用

// Example:
const chunkRes = ChunkRes();
// can`t use ref() to save task; it will lost task info
const task = wx.request({
  //...other params
  enableChunked: true,
  success: (res) => {
    const lastResTexts: string[] | undefined = chunkRes.onComplateReturn();
    // dosomething
  },
});
task.onChunkReceived((res) => {
  const resTexts: string[] | undefined = chunkRes.onChunkReceivedReturn(
    res.data
  );
  // dosomething
});
1.0.3

10 months ago

1.0.2

12 months ago

1.0.1

1 year ago

1.0.0

1 year ago