小编Eri*_*son的帖子

Flutter Dio Package:如何监听另一个类的下载进度?

我有一个DownloadsService类使用包处理文件下载dio。我想听一下我的ViewModel类中实现类downloadFile内方法的下载进度DownloadService。我该怎么做呢?

这是我的DownloadsService课程代码片段:

class DownloadsService {
   final String urlOfFileToDownload = 'http://justadummyurl.com/'; //in my actual app, this is user input
   final String filename = 'dummyfile.jpg';
   final String dir = 'downloads/$filename'; //i'll have it saved inside internal storage downloads directory

   void downloadFile() {
     Dio dio = Dio();
     dio.download(urlOfFileToDownload, '$dir/$filename', onReceiveProgress(received, total) {
        int percentage = ((received / total) * 100).floor(); //this is what I want to listen to from my ViewModel …
Run Code Online (Sandbox Code Playgroud)

progress stream listen flutter dio

5
推荐指数
1
解决办法
1万
查看次数

TypeOrm - 使用 queryBuilder 的 NestJS

我在 mysql 中有这个数据库模式:

     users_tbl
     --------------------------------------------
     id        |  first_name         | last_name
     --------------------------------------------
     1         |  Jon                | Doe
     2         |  Mark               | Smith


     address_tbl
     ------------------------------------------------------------
     id        |  address            | city             | user_id
     ------------------------------------------------------------
     1         |  some address       | some city        | 1
Run Code Online (Sandbox Code Playgroud)

然后,我想使用 TypeOrm 的 queryBuilder 来获取 Jon Doe 的地址。

我的原始 SQL 查询: SELECT users.first_name, users.last_name, address.address, address.city FROM users INNER JOIN address ON address.user_id=users.id

我的 TypeOrm 查询生成器:

const users = await this.userRepo
      .createQueryBuilder('users')
      .select('users.first_name', 'fName')
      .addSelect('users.last_name', 'lName')
      .addSelect('adr.address', 'address')
      .addSelect('adr.city', 'city') …
Run Code Online (Sandbox Code Playgroud)

mysql query-builder node.js typeorm nestjs

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

dio ×1

flutter ×1

listen ×1

mysql ×1

nestjs ×1

node.js ×1

progress ×1

query-builder ×1

stream ×1

typeorm ×1