Skip to content

Commit

Permalink
type cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jchris committed Feb 10, 2024
1 parent ad83dc4 commit 82cc108
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions packages/connect/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ export abstract class Connection {
await this.loader!.remoteWAL?._process()
}

connect({ loader }: { loader: Loader }) {
connect({ loader }: { loader: Loader | undefined }) {
if (!loader) throw new Error('loader is required')
this.connectMeta({ loader })
this.connectStorage({ loader })
}

connectMeta({ loader }: { loader: Loader }) {
connectMeta({ loader }: { loader: Loader | undefined}) {
if (!loader) throw new Error('loader is required')
this.loader = loader
this.taskManager = new TaskManager(loader)
this.onConnect()
Expand All @@ -74,7 +76,8 @@ export abstract class Connection {

async onConnect() {}

connectStorage({ loader }: { loader: Loader }) {
connectStorage({ loader }: { loader?: Loader }) {
if (!loader) throw new Error('loader is required')
this.loader = loader
loader!.remoteCarStore = new RemoteDataStore(this.loader!.name, this)
loader!.remoteFileStore = new RemoteDataStore(this.loader!.name, this, 'file')
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/useFireproof.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export function useFireproof(name: string | Database = "useFireproof", config: C
if (!newDoc) return void (opts.reset ? setDoc(initialDoc) : refreshDoc());
setDoc((d) => (opts.replace ? (newDoc as Doc<T>) : { ...d, ...newDoc }));
},
[refreshDoc]
[refreshDoc, initialDoc]
);

useEffect(() => {
Expand Down

0 comments on commit 82cc108

Please sign in to comment.