Cannot create observable from Observable.bindNodeCallback(fs.readFile) in TypeScript

后端 未结 2 1479
忘了有多久
忘了有多久 2021-01-12 03:18

I am trying to use rxjs 5 to write a Node.js server in TypeScript, but I hit an error when converting fs.readFile to its rxjs form. I expect the following code

2条回答
  •  囚心锁ツ
    2021-01-12 03:22

    To be honest i haven't found a solution, but in order to make it work, i cast it to a function.

    (Rx.Observable.bindNodeCallback(fs.readFile))('./file.txt', 'utf8').subscribe();
    

提交回复
热议问题