Distributed function execution via CRDT sync (aka. "Command" invokation).
Provides a way to invoke functions remotely via a principled API.
Beyond it's direct use, Cmd provides the foundations for a basic "actor system" implementation.
type P = { a: number; b: number };
type R = { sum: number };
type E = t.CmdError & { code: number; type: 'bounds' };
type C = C1 | C2 | C3;
type C1 = t.CmdType<'add', P, C2, E>;
type C2 = t.CmdType<'add:res', R>;
type C3 = t.CmdType<'foo', { msg?: string }>;
Invoke, no response:
cmd.invoke('foo', { msg: "👋" });
cmd.invoke('add', { a: 1, b: 2 }); // NB: doesn't make sense, as the response would be useful.
Cmd (Command)
Distributed function execution via CRDT sync (aka. "Command" invokation).
Provides a way to invoke functions remotely via a principled API.
Beyond it's direct use,
Cmd
provides the foundations for a basic "actor system" implementation.Command instantiation:
Sample command type definitions:
Invoke, no response:
Invoke response async/await:
Invoke response with callback:
Sample chained invocation call:
Sample command implementation (service):