Skip to content

Commit

Permalink
fix: using rcpReadable
Browse files Browse the repository at this point in the history
Signed-off-by: axel7083 <[email protected]>
  • Loading branch information
axel7083 committed Feb 14, 2024
1 parent b3f12e5 commit 7f1e468
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions packages/frontend/src/stores/localRepositories.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import type { Readable } from 'svelte/store';
import { readable } from 'svelte/store';
import { MSG_LOCAL_REPOSITORY_UPDATE } from '@shared/Messages';
import { rpcBrowser, studioClient } from '/@/utils/client';
import { studioClient } from '/@/utils/client';
import type { LocalRepository } from '@shared/src/models/ILocalRepository';
import { RPCReadable } from '/@/stores/rpcReadable';

export const localRepositories: Readable<LocalRepository[]> = readable<LocalRepository[]>([], set => {
const sub = rpcBrowser.subscribe(MSG_LOCAL_REPOSITORY_UPDATE, msg => {
set(msg);
});
// Initialize the store manually
studioClient.getLocalRepositories().then(state => {
set(state);
});
return () => {
sub.unsubscribe();
};
});
export const localRepositories: Readable<LocalRepository[]> = RPCReadable<LocalRepository[]>(
[],
[MSG_LOCAL_REPOSITORY_UPDATE],
studioClient.getLocalRepositories,
);

0 comments on commit 7f1e468

Please sign in to comment.