Skip to content

luoanb/chunk-res

Repository files navigation

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
});

About

微信小程序内实现http流式响应

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published