Comments (5)
Hi @Gregivy, setting autoConnect:false
when instantiating simpleddp did the trick (so you were probably right when you said that the server was responding too fast, because the connection was being establish on class instantiation).
A separate PR will follow with the typescript definition file.
from simpleddp.
Hello @joaopiopedreira, thank you for your response!
Have you tried something like this?
setTimeout(() => {
this.server.connect().then(() => {
console.log('this gets logged!');
}
},1000);
this.server.on('connected',()=>{
console.log('this does not get logged');
});
Will the both messages appear?
from simpleddp.
Hi @Gregivy, thank you for the quick reply. That didn't work, but the below did. I'll fork your project this evening and will try to debug why the core ddp emitter is not working. If I find anything, I'll post it here or send you a PR.
import simpleddp from "simpleddp";
import {config} from './meteor'
class App extends Component<IProps,IState> {
private server: simpleddp;
constructor(props) {
super(props);
this.server = config.server;
}
public async componentDidMount() {
this.server.connect().then(() => {
console.log('this gets logged!');
this.server.ddpConnection.emit('connected',{}); // <-------
}
this.server.on('connected',()=>{
console.log('this does not get logged');
});
}
(...)
}
On another note, are you interested in making this package typescript compatible? I'm writing a ...d.ts file as I move along and will soon be able to either submit a PR to DefinitelyTyped or directly to you and you include it in your source, as you prefer.
from simpleddp.
Hi again @Gregivy , maybe you should emit a connected
event here, something like
connect () {
this.autoReconnect = this.autoReconnectUserValue;
this.socket.open();
this.emit('connected',{...}) // <---------
}
from simpleddp.
Hi @joaopiopedreira, its great idea to support typescript definitions! I can merge your PR if you'd like or you can submit to DefinitelyType as you like more. It's up to you :)
What concerns the error you faced I think it may be due to the fact that connected
message comes from server too quick, quicker than you start listening for connected
events. Try to switch positions in code:
this.server.on('connected',()=>{
console.log('this does not get logged');
});
this.server.connect().then(() => {
console.log('this gets logged!');
}
If it won't help, I need to see your code example that reproduces this error (test repo suits perfect).
P.S. You can't emit connected
after this.socket.open();
because it doesn't match DDP protocol specification (https://github.com/meteor/meteor/blob/devel/packages/ddp/DDP.md).
from simpleddp.
Related Issues (20)
- Connecting to non-existent / listening endpoint HOT 4
- Use simple-DDP in the browser HOT 1
- Browser DDP call promise never resolves HOT 11
- Handling "connection error" HOT 6
- isReady() returns false right after "await ready()" promise HOT 16
- uncaught error when "nosub" message is received HOT 2
- How to set header? HOT 4
- server.on('event') HOT 2
- Custom Login Handler
- Meteor.loggingIn() equivalent HOT 4
- Struggling to get data from ddp endpoint HOT 2
- [Feature request] Set custom timeout for an specific server.call()
- Handle Offline or Inaccessible Server HOT 1
- Reactive subscribe args? HOT 2
- Empty data on fetch, and onChange does not work either HOT 1
- WebpackError: Unsafe builtin usage https.get
- Session disconnected and loginSessionLost event is not called
- can you add status check manually?
- Is there any solutions or workaround to connect with Android?
- Can use the methods, publish to custom login in another server with meteor?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simpleddp.