Skip to content

Instantly share code, notes, and snippets.

@gabrielstuff
Created January 22, 2014 22:20
Show Gist options
  • Save gabrielstuff/8568589 to your computer and use it in GitHub Desktop.
Save gabrielstuff/8568589 to your computer and use it in GitHub Desktop.
Deal with event and future
Meteor.methods({
'imapConnect': function(email, password) {
var fut = new Future(),
imap = new Imap({
user: email,
password: password,
host: host,
port: port,
tls: tls,
tlsOptions: {
rejectUnauthorized: false
}
});
imap.once('ready', function() {
console.log('imap connection open');
fut['return']('success');
});
imap.once('error', function(err) {
console.log(err);
fut['return'](err)
});
imap.once('end', function() {
console.log('Connection ended');
fut['return']('Connection ended');
});
imap.connect();
return fut.wait();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment