Skip to content

Correcting Reducer Callback Information in llms.md #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions llms.md
Original file line number Diff line number Diff line change
Expand Up @@ -2159,19 +2159,25 @@ private registerReducerCallbacks() {

this.conn.reducers.onSendMessage(this.handleSendMessageResult);
// Register other reducer callbacks if needed
// this.conn.reducers.onSetName(this.handleSetNameResult);
// this.conn.reducers.onSetName(handleSetNameResult);

// Note: Consider returning a cleanup function to unregister
}

private handleSendMessageResult(ctx: ReducerEventContext, messageText: string) {
const wasOurCall = ctx.reducerEvent.callerIdentity.isEqual(this.identity);
const wasOurCall = ctx.event.callerIdentity.isEqual(this.identity);
if (!wasOurCall) return; // Only care about our own calls here

if (ctx.reducerEvent.status === Status.Committed) {
switch(ctx.event.status.tag) {
case "Committed":
console.log(`Our message "${messageText}" sent successfully.`);
} else if (ctx.reducerEvent.status.isFailed()) {
console.error(`Failed to send "${messageText}": ${ctx.reducerEvent.status.getFailedMessage()}`);
break;
case "Failed":
console.error(`Failed to send "${messageText}": ${ctx.event.status.value}`);
break;
case "OutOfEnergy":
console.error(`Failed to send "${messageText}": Out of Energy!`);
break;
}
}

Expand Down