@@ -385,9 +385,9 @@ where
385
385
}
386
386
}
387
387
388
- /// This method sends batch of messages back to the component's loop when the
389
- /// returned callback is called.
390
- pub fn send_back_batch < F , IN > ( & mut self , function : F ) -> Callback < IN >
388
+ /// This method creates a `Callback` which will send a batch of messages back to the linked
389
+ /// component's update method when called.
390
+ pub fn batch_callback < F , IN > ( & self , function : F ) -> Callback < IN >
391
391
where
392
392
F : Fn ( IN ) -> Vec < COMP :: Message > + ' static ,
393
393
{
@@ -399,15 +399,16 @@ where
399
399
closure. into ( )
400
400
}
401
401
402
- /// This method sends messages back to the component's loop when the returned callback is called.
403
- pub fn send_back < F , IN > ( & mut self , function : F ) -> Callback < IN >
402
+ /// This method creates a `Callback` which will send a message to the linked component's
403
+ /// update method when invoked.
404
+ pub fn callback < F , IN > ( & self , function : F ) -> Callback < IN >
404
405
where
405
406
F : Fn ( IN ) -> COMP :: Message + ' static ,
406
407
{
407
408
let scope = self . scope . clone ( ) ;
408
409
let closure = move |input| {
409
410
let output = function ( input) ;
410
- scope. clone ( ) . send_message ( output) ;
411
+ scope. send_message ( output) ;
411
412
} ;
412
413
closure. into ( )
413
414
}
@@ -425,21 +426,17 @@ where
425
426
use wasm_bindgen:: JsValue ;
426
427
use wasm_bindgen_futures:: future_to_promise;
427
428
428
- let mut scope = self . scope . clone ( ) ;
429
-
430
- let js_future = async {
431
- let message: COMP :: Message = future. await ;
432
- // Force movement of the cloned scope into the async block.
433
- let scope_send = move || scope. send_message ( message) ;
434
- scope_send ( ) ;
429
+ let scope = self . scope . clone ( ) ;
430
+ let js_future = async move {
431
+ scope. send_message ( future. await ) ;
435
432
Ok ( JsValue :: NULL )
436
433
} ;
437
434
future_to_promise ( js_future) ;
438
435
}
439
436
440
437
/// This method sends a message to this component to be processed immediately after the
441
438
/// component has been updated and/or rendered.
442
- pub fn send_self ( & mut self , msg : COMP :: Message ) {
439
+ pub fn send_message ( & mut self , msg : COMP :: Message ) {
443
440
self . scope . send_message ( msg) ;
444
441
}
445
442
@@ -448,7 +445,7 @@ where
448
445
///
449
446
/// All messages will first be processed by `update`, and if _any_ of them return `true`,
450
447
/// then re-render will occur.
451
- pub fn send_self_batch ( & mut self , msgs : Vec < COMP :: Message > ) {
448
+ pub fn send_message_batch ( & mut self , msgs : Vec < COMP :: Message > ) {
452
449
self . scope . send_message_batch ( msgs)
453
450
}
454
451
}
0 commit comments