MCPcopy Create free account
hub / github.com/instantdb/instant / startWriteStream

Method startWriteStream

client/packages/core/src/Stream.ts:911–935  ·  view source on GitHub ↗
(opts: {
    clientId: string;
    reconnectToken: string;
    ruleParams?: RuleParams | null | undefined;
  })

Source from the content-addressed store, hash-verified

909 }
910
911 private startWriteStream(opts: {
912 clientId: string;
913 reconnectToken: string;
914 ruleParams?: RuleParams | null | undefined;
915 }): Promise<WriteStreamStartResult> {
916 const eventId = uuid();
917 let resolve: ((data: WriteStreamStartResult) => void) | null = null;
918 const promise: Promise<WriteStreamStartResult> = new Promise((r) => {
919 resolve = r;
920 });
921 this.startWriteStreamCbs[eventId] = resolve!;
922 const msg: StartStreamMsg = {
923 op: 'start-stream',
924 'client-id': opts.clientId,
925 'reconnect-token': opts.reconnectToken,
926 };
927
928 if (opts.ruleParams) {
929 msg['rule-params'] = opts.ruleParams;
930 }
931
932 this.trySend(eventId, msg);
933
934 return promise;
935 }
936
937 private registerWriteStream(streamId: string, cbs: WriteStreamCbs) {
938 this.writeStreams[streamId] = cbs;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected