Skip to content

Commit

Permalink
docs: update event docs (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
miraclx authored Oct 25, 2024
1 parent cc7539f commit 4e07970
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions docs/04-build/02-client-sdks/02-client-ts-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,34 +91,38 @@ export interface RpcMutateResponse<Output> {

```typescript
export interface SubscriptionsClient {
connect(connectionId?: string): void;
connect(connectionId?: string): Promise<void>;
disconnect(connectionId?: string): void;
subscribe(applicationIds: string[], connectionId?: string): void;
unsubscribe(applicationIds: string[], connectionId?: string): void;
addCallback(
callback: (event: NodeEvent) => void,
connectionId?: string,
): void;
subscribe(contextIds: string[], connectionId?: string): void;
unsubscribe(contextIds: string[], connectionId?: string): void;
addCallback(callback: (event: NodeEvent) => void, connectionId?: string): void;
removeCallback(
callback: (event: NodeEvent) => void,
connectionId?: string,
): void;
}

export type NodeEvent = ApplicationEvent;
export type NodeEvent = ContextEvent;

export interface ApplicationEvent {
application_id: ApplicationId;
type: 'TransactionExecuted' | 'PeerJoined';
data: TransactionExecuted | PeerJoined;
export type ContextEvent = ContextEventPayload & {
contextId: ContextId;
}

export interface TransactionExecuted {
hash: string;
type ContextEventPayload = {
type: 'StateMutation',
data: StateMutation,
} | {
type: 'ExecutionEvent',
data: ExecutionEvent,
};

export interface StateMutation {
newRoot: string;
}

export interface PeerJoined {
peerId: string;
export interface ExecutionEvent {
kind: string,
data: any,
}
```

Expand Down

0 comments on commit 4e07970

Please sign in to comment.