为什么 Node RxJS .subscribe() 没有被 bindNodeCallback() 触发?

Why is Node RxJS .subscribe() not being triggered with bindNodeCallback()?

我正在学习如何将 RxJS 与 Node.js 结合使用。查看示例 (1, 2 (old), ),我目前无法触发 .subscribe():

中的 'results' 或 'err' 方法
const fs = require('fs');
const { bindNodeCallback } = require('rxjs');

const configPath = './config/config.yml';
const configEncoding = 'utf8';

// also tried with bindCallback()...
const readFileSync = bindNodeCallback(fs.readFileSync);

readFileSync(configPath, configEncoding)
.subscribe(
  results => console.log(results), 
  err => console.error(err)
);

// temporary, exits immediately otherwise
// hmmm clue to the above not being correct?...
setInterval(() => { let keep = 'going'; }, 1000);

我正在使用 "rxjs": "^6.4.0",节点 v10.14.2。

我如何更改此代码以便我的观察者观察配置文件加载?

您应该使用 readFile 而不是 readFileSync,因为 readFileSync 不能使用回调。

https://nodejs.org/api/fs.html#fs_fs_readfilesync_path_options