Messages

Typed requests between resources on the same side. One resource handles a message type, and others send to it or ask it and wait for a reply.

messages.handle()

Messages.handle(type, handler)

Handles a message type for this resource. The handler receives the payload and a reply function. Call reply(value) to answer a request.

messages.request()

Messages.request(name, type, payload)

Sends a message to another resource and resolves to its reply. Rejects if that resource or handler does not exist, the handler throws, or either resource stops. There is no built-in time limit, so a handler that never replies leaves it waiting.

messages.send()

Messages.send(name, type, payload)

Sends a message to another resource without waiting for a reply. Nothing happens if it has no handler for the type.