Capability first · transport second

CommunicationHub.js

Fans out provider refresh/send operations and aggregates normalized threads/messages.

SDK 0.5.18Runtime 0.8.12Protocol arcane/1
On this page

Overview

Fans out provider refresh/send operations and aggregates normalized threads/messages.

  • Artifact
    CommunicationHub.js · esm
  • Classification
    public first party
  • Availability
    Cross-host with injected providers
  • Normalization
    Normalized aggregates; refresh contains per-provider failures.

Import and lifecycle

JavaScript
import * as module from '/arcane/modules/CommunicationHub.js';

refresh fans out provider reads and emits an aggregate event; messages reads one provider and send performs one provider write.

Application-facing behavior: Event/state/reason/error constants; default CommunicationHub; provider enablement, refresh(), messages(), send(), state-free EventTarget/on compatibility, and dispose().

Protocol and host implementation

Injected provider contract + per-realm globalThis.arcaneEvents authority This detail does not widen the application-facing API or grant authority.

Exports, signatures, parameters, and results

BindingFormDeclaration or signatureParameter syntax
COMMUNICATION_HUB_EVENTSvariable · valuevariable COMMUNICATION_HUB_EVENTS
COMMUNICATION_HUB_REFRESH_STATESvariable · valuevariable COMMUNICATION_HUB_REFRESH_STATES
COMMUNICATION_HUB_REFRESH_REASONSvariable · valuevariable COMMUNICATION_HUB_REFRESH_REASONS
COMMUNICATION_HUB_ERROR_CODESvariable · valuevariable COMMUNICATION_HUB_ERROR_CODES
defaultdefault · classclass CommunicationHub extends EventTarget
CallableKindExact public signatureParameter syntax
CommunicationHub.refreshpublic-memberasync refresh(options={})options={}
CommunicationHub.messagespublic-memberasync messages(thread)thread
CommunicationHub.sendpublic-memberasync send({providerId,threadId,channel,body,subject='',recipients=[]}={}){providerId,threadId,channel,body,subject='',recipients=[]}={}
MemberKindExact public declarationParameter syntax
CommunicationHub.constructorconstructorconstructor({providers=[],enabledProviderIds=[]}={}){providers=[],enabledProviderIds=[]}={}
CommunicationHub.addEventListenermethodaddEventListener(type,listener,options)type,listener,options
CommunicationHub.removeEventListenermethodremoveEventListener(type,listener,options)type,listener,options
CommunicationHub.onmethodon(type,listener,options)type,listener,options
CommunicationHub.dispatchEventmethoddispatchEvent(value)value
CommunicationHub.setEnabledmethodsetEnabled(ids=[])ids=[]
CommunicationHub.enabledProvidersmethodenabledProviders()
CommunicationHub.refreshasync methodasync refresh(options={})options={}
CommunicationHub.messagesasync methodasync messages(thread)thread
CommunicationHub.sendasync methodasync send({providerId,threadId,channel,body,subject='',recipients=[]}={}){providerId,threadId,channel,body,subject='',recipients=[]}={}
CommunicationHub.disposemethoddispose()
CommunicationHub.destroymethoddestroy()

Parameter meanings and results

Construct with {providers, enabledProviderIds}. refresh returns {threads, errors}; messages(thread) returns timestamp-sorted CommunicationMessages; send(options) returns the provider result.

Events, side effects, and errors

Source-literal CustomEvent dispatches

No source-literal CustomEvent dispatch is part of this artifact.

Lifecycle and event flow

  • communications-refresh-started
  • communications-refresh-completed
  • communications-refresh-partially-completed
  • communications-refresh-failed
  • communications-refresh-cancelled

Direct coded failures

This artifact directly assigns no stable coded failure.

Exported Error subclasses

This artifact exports no Error subclass.

Documented failure behavior

  • TypeError for an empty body
  • registry, entity, and provider errors propagate
  • refresh captures per-provider failures in errors

Availability and capabilities

Cross-host with injected providers. Normalized aggregates; refresh contains per-provider failures.

Normalizes injected providers and partial failure without requiring Core.

Contract example

JavaScript
import CommunicationHub from '/arcane/modules/CommunicationHub.js';

const provider={
    id:'demo',
    label:'Demo',
    channels:['other'],
    listThreads:async()=>[],
    getMessages:async()=>[],
    send:async input=>input
};
const hub=new CommunicationHub({providers:[provider],enabledProviderIds:['demo']});
console.log(await hub.refresh());

No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.