Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
"react-dom": ">=16.0 <18.0",
"replicache": ">=4.0.1 <10.0 || >7.0.0-beta <7.0.0 || >8.0.0-beta <8.0.0 || >9.0.0-beta <9.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know why did this package need replicache as a dependency in the first place? It seems like since we are not constructing it, all we should need is the type, and only then at dev time... So it seems like this should have worked with replicache as a devDependency and nothing else.

Copy link
Contributor Author

@grgbkr grgbkr Apr 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could have always been an optional peer dependency (in older versions of npm all peer dependencies were optional). But we still need the peer dependency to specify what versions of replicache this is compatible with.

},
"peerDependenciesMeta": {
"replicache": {
"optional": true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting.

}
},
"devDependencies": {
"@esm-bundle/chai": "^4.3.4-fix.0",
"@snowpack/web-test-runner-plugin": "^0.2.2",
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ function doCallback() {
});
}

export type Subscribeable = Pick<Replicache, 'subscribe'>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I was thinking was actually describing the subscribe interface. But now that I see maybe why you didn't want to do that - the subscribe interface is large and detailed. It could also fall behind head of either Replicache or Reflect.

What if instead we have this package just directly depend on Replicache and Reflect and have the argument be Replicache|Reflect.

I think that is fine, it's not going to add to the compile size, or even the install size for our users -- it just means when we work on this we install both packages.


export function useSubscribe<R extends ReadonlyJSONValue>(
rep: Replicache | null | undefined,
rep: Replicache | Subscribeable | null | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need both Replicache and Subscribeable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was debating this. I think it makes it more obvious to customers that they can pass Replicache here... it still not obvious that they can pass ReflectClient.

I think something like:
subscribable: Replicache | ReflectClient | null | undefined
might me more obvious.

query: (tx: ReadTransaction) => Promise<R>,
def: R,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down