It would be nice to have a way to use Server-Side Events (SSE) in commands. SSE is a technology that allows a client to receive partial real-time updates from a server using an HTTP connection that is kept alive during the process. This feature can be useful for client applications that need to implement partial updates as some long-during action is performed.
For example, imagine a command that triggers a complex workflow that involves multiple steps and takes some time to complete. The client application could use SSE to receive notifications about the progress of each step and update the UI accordingly.
Possible Solution
One possible solution is to add a new method to the Register class that allows sending events to the client. For example:
@Command({
authorize: 'all'
})
export class MyCommand {
public constructor(
readonly field1: string,
readonly field2: string
) {}
public async handle(register: Register): Promise<void> {
// Do some initial work
register.sendEvent('Step 1 completed')
// Do some more work
register.sendEvent('Step 2 completed')
// Finalize work
register.sendEvent('Done')
}
}
The sendEvent method would deliver the events to the client via SSE.
Additional information
There is an open question about how to implement SSE over GraphQL, since Booster Framework uses GraphQL mutations to access commands. There are two possible options:
Option 1: Use a separate endpoint and a protocol that implements the GraphQL over SSE technique described here.
Option 2: Implement the possibility to run commands over a WebSocket,making it possible for the client to subscribe to partial updates.
It would be a good idea to perform a small research on these options and decide which one is more suitable or if there are other options.
Feature Request
Description
It would be nice to have a way to use Server-Side Events (SSE) in commands. SSE is a technology that allows a client to receive partial real-time updates from a server using an HTTP connection that is kept alive during the process. This feature can be useful for client applications that need to implement partial updates as some long-during action is performed.
For example, imagine a command that triggers a complex workflow that involves multiple steps and takes some time to complete. The client application could use SSE to receive notifications about the progress of each step and update the UI accordingly.
Possible Solution
One possible solution is to add a new method to the Register class that allows sending events to the client. For example:
The sendEvent method would deliver the events to the client via SSE.
Additional information
There is an open question about how to implement SSE over GraphQL, since Booster Framework uses GraphQL mutations to access commands. There are two possible options:
It would be a good idea to perform a small research on these options and decide which one is more suitable or if there are other options.