sycamore x futures
2022-03-29 · 2 min read
Spawn a future on the current thread. Must be
'static and so can't contain any
ScopeRefs or w/e:
!Send future (which can contain
use sycamore::futures::ScopeSpawnFuture; ctx.spawn_future(future);
Future<U> to a
use sycamore::futures::ScopeFuturesExt; ctx.create_resource(future);
Web Workers #
Like threads for browser (but worse lol). No shared memory allowed; only serialized message passing. Workers can't manipulate the DOM.
SharedWorkers (also "Public" workers) are a special kind of worker that can be accessed from multiple browser windows, tabs, or other workers. There can only exist one instance at a time.
- "Private" workers can be fired up and down at-will. Good for farming out work.
Communicating with workers:
- Bridges allow bidi comms b/w worker and component (or other workers).
- Dispatchers allow uni comms from component to worker.