mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-08-25 21:04:04 +02:00
Route all app commands through a single RPC envelope (#542)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
1f91cddab9
commit
23e7229e63
@@ -30,21 +30,22 @@ export function watchWorkspaceFiles(
|
||||
callback: (e: WatchEvent) => void,
|
||||
) {
|
||||
console.log("Watching workspace files", workspaceId, syncDir);
|
||||
const unlistenPromise = platform.rpcStream<WatchResult, WatchEvent>(
|
||||
const handle = platform.rpcStream<WatchResult, WatchEvent>(
|
||||
"cmd_sync_watch",
|
||||
{ workspaceId, syncDir },
|
||||
callback,
|
||||
);
|
||||
|
||||
void unlistenPromise.then(({ unlistenEvent }) => {
|
||||
addWatchKey(unlistenEvent);
|
||||
void handle.then(({ result }) => {
|
||||
addWatchKey(result.unlistenEvent);
|
||||
});
|
||||
|
||||
return () =>
|
||||
unlistenPromise
|
||||
.then(async ({ unlistenEvent }) => {
|
||||
handle
|
||||
.then(async ({ result, unlisten }) => {
|
||||
console.log("Unwatching workspace files", workspaceId, syncDir);
|
||||
unlistenToWatcher(unlistenEvent);
|
||||
unlistenToWatcher(result.unlistenEvent);
|
||||
unlisten();
|
||||
})
|
||||
.catch(console.error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user