我有一个传奇观察者:
function* watchSetRefreshInterval() {
yield takeLatest(SET_LOOP, setLoop);
}
Run Code Online (Sandbox Code Playgroud)
和一个setLoop传奇
function* setLoop() {
yield put({type: ANOTHER_WATCHER });
}
Run Code Online (Sandbox Code Playgroud)
我想yield put({type: ANOTHER_WATCHER });间隔发生
这不起作用
setTimeout(function timeoutFn(){
yield put({type: ANOTHER_WATCHER });
setTimeout(timeoutFn, 5000);
}, 5000);
Run Code Online (Sandbox Code Playgroud)
您不能yield在非生成器函数中使用,使timeoutFn生成器也无法正常工作。
我怎样才能yield put在一个时间间隔内打电话。我不想使用
while(true) {
yield delay(5000);
yield put({type: ANOTHER_WATCHER });
}
Run Code Online (Sandbox Code Playgroud)
我想使用setTimeout功能。
我无法发送到SSL上的smtp服务器.
我正在使用lettre"0.8".
我尝试过使用lettre :: smtp中的SmtpTransportBuilder
use native_tls::TlsConnector;
use native_tls::{Protocol};
use lettre::smtp::authentication::{Credentials, Mechanism};
use lettre::{SimpleSendableEmail, EmailTransport, SmtpTransport, ClientTlsParameters, ClientSecurity};
use lettre::smtp::extension::ClientId;
use lettre::smtp::ConnectionReuseParameters;
use lettre::smtp::{SmtpTransportBuilder};
fn main() {
env_logger::init();
let email = SimpleSendableEmail::new(
"from@host.com".to_string(),
&["to@host.com".to_string()],
"message_id".to_string(),
"Hello world".to_string(),
).unwrap();
pub const DEFAULT_TLS_PROT: &[Protocol] = &[Protocol::Sslv3];
let mut tls_builder = TlsConnector::builder().unwrap();
tls_builder.supported_protocols(DEFAULT_TLS_PROT).unwrap();
let tls_parameters =
ClientTlsParameters::new("smtp.gmail.com".to_string(), tls_builder.build().unwrap());
pub const SUBMISSION_PORT: u16 = 465;
let mut mailer = SmtpTransportBuilder::new(("smtp.gmail.com", SUBMISSION_PORT), ClientSecurity::Required(tls_parameters))
.authentication_mechanism(Mechanism::Login)
.credentials(Credentials::new("USER".to_string(), "PASS".to_string()))
.connection_reuse(ConnectionReuseParameters::ReuseUnlimited)
.build();
let result_1 = mailer.send(&email);
assert!(result_1.is_ok());
mailer.close();
} …Run Code Online (Sandbox Code Playgroud)