-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFE: Expose clientID on Read/WriteTransaction #541
Comments
@arv - agreed? If so can we add |
Easy to do. If you say it has high value lets do it. |
OK specific API proposal:
:-). We could have a discussion about method vs property, but I like signaling to user that there is zero overhead to this call (it doesn't need to be cached). |
Started looking into this. Currently
For Currently Options
|
Ah, good observation. Separately I filed an RFE about It was thought that this feature enhancement here partly subsumes #542, but it wouldn't if we make There is also an option 4: to have ... or alternately option 5: extract out a separate interface, maybe called Of these I suppose I like your option 2 best. I'm not sure there's any value to having |
A fourth alternative is to have I think I'm leaning towards 1 or 2. Having |
Wait actually @arv - master of the versioning - would making This gets super deep into: are our typescript types part of our interface? I guess so yes. Is whether you implement a type (by name) part of your interface? I think I could construct situations where changing this would be detectible by users and break them, but it would be difficult! |
You are right. This is not a breaking change if the interface that has interface ReadTransactionNewName extends ReadTransaction {
readonly clientID: string;
} |
Thanks for the input. Regarding Aaron's I thought about Aaron's option 5 I'm pretty convinced I'm going to put together a PR for my option 2 ( |
Option 2 FTW |
Great argument. 100% convinced, thanks! |
…ion, deprecate methods Update Replicache class to no longer implement ReadTransactionbecause while Replicache exposing these methods is slightly convenient Replicache's implementation is not actually transactional and thus cannot safely be passed to any function expecting a transaction it makes it difficult to add a non-Promise property for clientID to the ReadTransaction interface (see RFE: Expose clientID on Read/WriteTransaction #541) Currently does not remove ReadTransaction methods from Replicache, but marks them as deprecated, pointing to Replicache#query. These methods will be removed in the next major release.
…ion, deprecate methods (#612) Update Replicache class to no longer implement ReadTransactionbecause while Replicache exposing these methods is slightly convenient Replicache's implementation is not actually transactional and thus cannot safely be passed to any function expecting a transaction it makes it difficult to add a non-Promise property for clientID to the ReadTransaction interface (see RFE: Expose clientID on Read/WriteTransaction #541) Currently does not remove ReadTransaction methods from Replicache, but marks them as deprecated, pointing to Replicache#query. These methods will be removed in the next major release. Co-authored-by: Gregory Baker <greg@roci.dev>
…teTransaction (#617) fix: Fix deadlock/transaction issues with expose clientID on Read/WriteTransaction This change 1. Addresses arv's feedback on PR feat: Expose clientID on ReadTransaction #613 2. Fixes issue where awaiting clientID inside a dag transaction was causing deadlocks and/or prematurely closing idb transactions. 3. Restructures Replicache#_open to avoid unnecessarily delaying the resolution of _clientIDPromise (currently blocks on db initialization and this._getRoot). Closes #541
This had to be reverted due to an unexpected perf regression in populate and createIndex performance tests Will investigate underlying cause and attempt to fix and re-land. |
Exposes clientID on ReadTransaction (and subclasses, e.g. WriteTransaction, IndexTransaction, etc). This change was previously reverted due to it causing perf test regressions. The underlying cause of those regressions was addressed in commit cc2bbeb. BREAKING CHANGE: The Replicache class no longer duck-types as a ReadTransaction (prior to 52bab5d Replicache explicitly implemented ReadTransaction). Any place where Replicache is assigned or passed as a ReadTransactio will need to be udpated, most likely to use Replicache.query. Closes #541
Exposes clientID on ReadTransaction (and subclasses, e.g. WriteTransaction, IndexTransaction, etc). This change was previously reverted due to it causing perf test regressions (976bf98, 4da3f52). The underlying cause of those regressions was addressed in commit cc2bbeb. BREAKING CHANGE: Due to the new property on ReadTransaction the Replicache class no longer duck-types as a ReadTransaction (prior to 52bab5d Replicache explicitly implemented ReadTransaction). Any place where Replicache is assigned or passed as a ReadTransaction will need to be updated, most likely to use Replicache.query. Closes #541
Many mutators in multiplayer apps end up taking the clientID as a parameter. It would be nice if it was implicitly available.
This would also allow for a nice symmetry with the subscription functions, which can already be written to rely on the clientID implicitly, because they only run on client side and can therefore grab it out of some other state.
The text was updated successfully, but these errors were encountered: