pub struct ComponentExecutor<TMsg> { /* private fields */ }
Expand description
Запуск коллекции компонентов в работу
§Примеры
§Многопоточное окружение
TODO
§Однопоточное окружение
TODO
§Однопоточное окружение - WASM (Leptos)
use leptos::*;
let context = LocalSet::new();
context.spawn_local(async move {
ComponentExecutor::<Message>::new(100, "example")
.add_cmp(cmp_websocket_client_wasm::Cmp::new(ws_client_config))
.add_cmp(cmp_leptos::Cmp::new(leptos_config))
.wait_result()
.await?;
Ok(()) as anyhow::Result<()>
});
spawn_local(context);
Ok(())
Implementations§
Source§impl<TMsg> ComponentExecutor<TMsg>where
TMsg: MsgDataBound + 'static,
impl<TMsg> ComponentExecutor<TMsg>where
TMsg: MsgDataBound + 'static,
Sourcepub fn new(config: ComponentExecutorConfig<TMsg>) -> Self
pub fn new(config: ComponentExecutorConfig<TMsg>) -> Self
Создание коллекции компонентов
Sourcepub fn add_cmp(self, component: impl IComponent<TMsg> + Send + 'static) -> Self
pub fn add_cmp(self, component: impl IComponent<TMsg> + Send + 'static) -> Self
Добавить компонент
Sourcepub async fn wait_result(&mut self) -> Result<(), ComponentError>
pub async fn wait_result(&mut self) -> Result<(), ComponentError>
Запустить на выполнение все компоненты.
Компоненты не должны заканчивать выполнение. Если хоть один остановился (неважно по какой причине - по ошибке или нет), это ошибка выполнения.
Auto Trait Implementations§
impl<TMsg> Freeze for ComponentExecutor<TMsg>
impl<TMsg> !RefUnwindSafe for ComponentExecutor<TMsg>
impl<TMsg> Send for ComponentExecutor<TMsg>
impl<TMsg> Sync for ComponentExecutor<TMsg>
impl<TMsg> Unpin for ComponentExecutor<TMsg>
impl<TMsg> !UnwindSafe for ComponentExecutor<TMsg>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more