attachHostBridge method
Future<void>
attachHostBridge({
- required Iterable<
AtomCategory> atoms, - required Iterable<
String> allowedAtoms,
Attach the host bridge. Atoms allowed by allowedAtoms are
surfaced inside the worker's host.*. The atoms list provides
the verb names + the live atom instances the dispatcher will
invoke.
Implementation
Future<void> attachHostBridge({
required Iterable<AtomCategory> atoms,
required Iterable<String> allowedAtoms,
}) async {
final iso = await _ensureIsolate();
final byKey = <String, AtomCategory>{
for (final a in atoms) a.key: a,
};
await iso.attachHostBridge(
atoms: atoms,
allowedAtoms: allowedAtoms,
dispatch: (atomKey, verb, args) async {
final atom = byKey[atomKey];
if (atom == null) {
throw ArgumentError('atom "$atomKey" not exposed to bundle');
}
return atom.dispatch(verb, args);
},
);
}