Reactive-Extensions / RxJS Implementation in node.js

I just want to implement

https://github.com/Reactive-Extensions/RxJS

into my node project.

Of course, there is an npm package available, but I see it as less updated, fewer modules and only uses min. files, so I want to use rxjs from git sources.

I downloaded RxJS-master and copied all the files under Dir to .. / myProject / lib / rx /

I see

rx.node.js among these files

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; 

so my app.js code is like this

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

This gives the following error:

 .../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 

What's wrong?


If I change rx.node.js to

 var Rx = require('./rx'); module.exports = Rx; 

The code works as expected, so obviously it is required - the auxiliary modules section is not suitable.


Thanks.

+4
source share
3 answers

Fixed from last build and I removed the wrong build with this commit

Updated NPM to remove 2.1.1 and replace with non-broken version.

+5
source

This is similar to the build problem you are using, and I assume this is 2.1.1. I had the same problem and the following npm commands fixed this for me.

 npm remove rx npm install rx@2.1.0 

EDIT: I see that you are using the wizard. Sorry for the confusion. This solution may work for others running 2.1.1.

0
source

I think you can do it. If this command:

 $ which npm /usr/local/bin/npm 

You can do it:

 $ npm remove rx $ npm install -g rx 

If you don't have anything for "npm", you can remove the node using this problem (best answer) and reinstall using brew (with MacOS) or your package manager:

 $ brew update $ brew uninstall node $ brew install node 

and you can use this:

 $ brew postinstall node 

In accordance with the discussion of this problem .

-1
source

Source: https://habr.com/ru/post/1469137/


All Articles