New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move rxjs to peerDependencies to allow custom versions usage #53
Comments
Hi @artaommahe ! This worked for me: import { Observable } from 'rxjs/Observable';
import "rxjs/add/operator/catch";
import "rxjs/add/observable/empty"; I'm importing |
@beagleknight yep, i tried this cases and have an error.. |
I think you are missing a this.client.send(pattern, data)
.catch((err: any) => { console.log('error', err); return Observable.empty(); })
.subscribe(...) I have this code working: const dogs = await this.client.send({ cmd: "woof" }, [])
.catch((err) => Observable.of(err))
.toPromise(); |
I uploaded the code to a public repository so you can check it 😄 |
Yeah, missing return in catch, also, FYI |
i miised, but error marks
I found a reason - having IMHO this should be fixed via moving |
@artaommahe Peer deps is deprecated with npm3 if I recall. You're able to use whatever version of rxjs you wish without issue regardless of what version Nest uses, assuming you have npm3 installed (I'm currently doing this now). Given the above error, I'd assume you need to be sure you include the full Rx library if you want to use catch, or use the operator add import to import it. Have a look at the import section under Installation and Usage here:
or
edit: just reread the OP, I see you tried the import. Taking another look |
As far as the dependencies - grep 'rxjs@5.4.0' in my
|
ofc it will be here due to
to
open
|
perhaps you're misreading that Note that 5.4.0 is a primary dependency and 5.0.3 is a 2nd or "peer" but npm3 nests it under Nest
Here's my dependencies block: "dependencies": {
"bcrypt-as-promised": "^1.1.0",
"body-parser": "^1.17.1",
"jsonwebtoken": "^7.4.0",
"mysql": "^2.13.0",
"nest.js": "1.0.6",
"passport": "^0.3.2",
"passport-jwt": "^2.2.1",
"reflect-metadata": "0.1.10",
"rxjs": "^5.4.0",
"typeorm": "0.0.11",
"typescript": "^2.2.1"
}, and here's a snippet of my use of catch
|
@zachgrayio yep, missed it. But there is still an error for example repo above with added to tsconfig rxjs lib. |
I don't use yarn much, but off top of my head, I'm wondering if you have a cached version of rxjs in yarn and it's still using it instead of 5.4.0 dependency you added to your package.json. under npm, when changing versions im always sure to have you run a |
@zachgrayio you can simply repeat it with npm (just made it)
add rxjs to package.json dependencies list
open |
alright, ill take a look |
Looks like an rxjs5 modularity issue. Making this change in client-prox.d.ts solves the issue it seems: import * as Rx from 'rxjs/Rx'; // import all of rx. using the operator add import HERE solves the issue too
import { Observer } from 'rxjs/Observer';
export declare abstract class ClientProxy {
abstract sendSingleMessage(pattern: any, callback: any): any;
send<T>(pattern: any, data: any): Rx.Observable<T>;
createObserver<T>(observer: Observer<T>): (err: any, result: any) => void;
} Might be best to open an issue over on rxjs to see what the preferred solution here is, I'm not entirely sure - though seems like its probably a pretty common issue. |
In the meantime though, this works either way because subscribe is always present on Observable. this.client.send<string>({ cmd: "woof" }, [])
.subscribe(
dogs => {
res.status(HttpStatus.OK).json(dogs);
}, e => {
console.log(e);
}) also its worth noting that you were returning an edited to add: perhaps some attention should be given to method |
@zachgrayio yep, i understand that it's too synthetic case with |
@zachgrayio also i dont find anything about
and old blog posts about deprecation without smth official |
To be clear, this isn't a problem with bringing in other versions of Rx alongside Nest. I've done this just fine a few times. The issue is really that use of |
Cause there is 2 different |
Hi @artaommahe, |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Error for client example from https://kamilmysliwiec.gitbooks.io/nest/content/real-time/microservices/basics.html
this does not help
skipping via
provides error at runtime
The text was updated successfully, but these errors were encountered: