未加星标

Reactive-Extensions / RxJS Implementatation to node.js

字体大小 | |
[前端(javascript) 所属分类 前端(javascript) | 发布者 店小二03 | 时间 2019 | 作者 红领巾 ] 0人收藏点击收藏

I simply want to implement

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

to my node project.

Surely, there is the npm-package available, but I see it less updated, less modules, and uses only min. files, so I want to use rxjs from git sources.

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

I see

rx. node.js among those 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.<strong>node.js</strong>") 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 an error as follows,

.../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.<strong>node.js</strong>:3:1) Process finished with exit code 1

What is wrong?

If I modify rx. node.js to

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

The code works as expected, so obviously require - sub modules section does not go well.

Thanks.

Problem courtesy of: Ken OKABE

Solution

Fixed as of the latest build and I removed the bad build in question with this commit

NPM has been updated accordingly to remove 2.1.1 and replaced with a non-broken version.

Solution courtesy of: Matthew Podwysocki

Discussion

I think you can do this. If this command:

$ which npm /usr/local/bin/npm

You can do this:

$ npm remove rx $ npm install -g rx

If you dont have nothing for "which npm" it can you must to remove node with this issue (the best answer) and reinstall with brew (with MacOS) or your package manager:

$ brew update $ brew uninstall node $ brew install node

and it can you must to use this:

$ brew postinstall node

According to the discussion on this issue .

Discussion courtesy of: Fernando Rguez.

This looks like a problem with the build that you are running, which I assume is 2.1.1. I had the same problem and the following npm commands fixed it for me.

npm remove rx npm install rx@2.1.0

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

Discussion courtesy of: KoboldAtWork

This recipe can be found in it's original form on Stack Over Flow .

本文前端(javascript)相关术语:javascript是什么意思 javascript下载 javascript权威指南 javascript基础教程 javascript 正则表达式 javascript设计模式 javascript高级程序设计 精通javascript javascript教程

代码区博客精选文章
分页:12
转载请注明
本文标题:Reactive-Extensions / RxJS Implementatation to node.js
本站链接:https://www.codesec.net/view/627759.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 前端(javascript) | 评论(0) | 阅读(227)