Skip to content

Commit

Permalink
Update usage of func
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh committed Nov 8, 2023
1 parent 10f8b46 commit 75b1576
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
20 changes: 13 additions & 7 deletions components/dashboard/src/service/json-rpc-workspace-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ export class JsonRpcWorkspaceClient implements PromiseClient<typeof WorkspaceSer
throw new ConnectError("signal is required", Code.InvalidArgument);
}
const it = generateAsyncGenerator<WorkspaceInstance>(
(sink) => {
const dispose = getGitpodService().registerClient({
onInstanceUpdate: (instance) => {
sink.next(instance);
},
});
return dispose.dispose;
(queue) => {
try {
const dispose = getGitpodService().registerClient({
onInstanceUpdate: (instance) => {
queue.push(instance);
},
});
return () => {
dispose.dispose();
};
} catch (e) {
queue.fail(e);
}
},
{ signal: options.signal },
);
Expand Down
18 changes: 11 additions & 7 deletions components/server/src/workspace/workspace-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,13 +736,17 @@ export class WorkspaceService {

public watchWorkspaceStatus(userId: string, opts: { signal: AbortSignal }) {
return generateAsyncGenerator<WorkspaceInstance>((sink) => {
const dispose = this.subscriber.listenForWorkspaceInstanceUpdates(userId, (_ctx, instance) => {
sink.next(instance);
});
return () => {
console.log("=============dispose");
dispose.dispose();
};
try {
const dispose = this.subscriber.listenForWorkspaceInstanceUpdates(userId, (_ctx, instance) => {
sink.push(instance);
});
return () => {
console.log("=============dispose");
dispose.dispose();
};
} catch (e) {
sink.fail(e);
}
}, opts);
}

Expand Down

0 comments on commit 75b1576

Please sign in to comment.