我只想实施 https://github.com/Reactive-Extensions/RxJS 到我的节点项目. 当然,有npm-package可用,但我看到它更新更少,模块更少,并且只使用min.文件,所以我想从git源使用rxjs. 我下载了RxJS-master并将
https://github.com/Reactive-Extensions/RxJS
到我的节点项目.
当然,有npm-package可用,但我看到它更新更少,模块更少,并且只使用min.文件,所以我想从git源使用rxjs.
我下载了RxJS-master并将Dir下的所有文件复制到../myProject/lib/rx/
我知道了
这些文件中的rx.node.js
var Rx = require('./rx'); require('./rx.aggregates'); require('./rx.binding'); require('./rx.coincidence'); require('./rx.experimental'); require('./rx.joinpatterns'); require('./rx.testing'); require('./rx.time'); module.exports = Rx;
所以,我的app.js代码是这样的
var rx = require("./lib/rx/rx.node.js") function test() { var as = new rx.AsyncSubject() setTimeout(function () { as.onNext("works!") as.onCompleted() }, 500) return as } var a = test().subscribe(function (result) { console.log("Got result: " + result) })
这给出了如下错误,
.../rx/lib/rx/rx.binding.js:173 var BehaviorSubject = Rx.BehaviorSubject = (function (_super) { ^ ReferenceError: Rx is not defined at .../rx/lib/rx/rx.binding.js:173:27 at Observable (.../rx/lib/rx/rx.binding.js:14:26) at Object.<anonymous> (.../rx/lib/rx/rx.binding.js:18:2) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:362:17) at require (module.js:378:17) at Object.<anonymous> (.../rx/lib/rx/rx.node.js:3:1) Process finished with exit code 1
怎么了?
如果我修改
rx.node.js到
var Rx = require('./rx'); module.exports = Rx;
代码按预期工作,因此显然需要 – 子模块部分不顺利.
谢谢.
修复了最新版本,我用 this commit删除了有问题的错误版本NPM已相应更新以删除2.1.1并替换为非破坏版本.