-
Notifications
You must be signed in to change notification settings - Fork 96
feat(zero): offline #4652
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
feat(zero): offline #4652
Conversation
@0xcadams is attempting to deploy a commit to the Rocicorp Team on Vercel. A member of the Team first needs to authorize it. |
|
||
const raceResult = await promiseRace([sleep(5000), result.server]); | ||
if (raceResult === 0) { | ||
// TODO show toast |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want this to be a toast?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we should rely on a new global onError
handler that Matt is constantly wanting to add. It is half-implemented in the codebase right now, but we got distracted by API design questions and never finished it.
I don't want every mutator to have to do this kind of error handling manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense - agreed it would be much better to have this in onError
. So I can add this toast later and only have this PR include online indicator, once the onError handler lands.
I'm confused - we already have |
@alexhking can you design an online indicator for zbugs? Note that people will probably copy whatever we do into their apps. Here are my product thoughts:
|
Yeah I can do that - it just means managing that state in two places and adds a new Context. Will change. |
I am missing something.... it seems trivial to wrap a hook around the existing feature. I don't get why any change is needed in zero.ts. |
Oooh it is because there can be many hooks, but there can only be one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I like this.
|
||
const raceResult = await promiseRace([sleep(5000), result.server]); | ||
if (raceResult === 0) { | ||
// TODO show toast |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we should rely on a new global onError
handler that Matt is constantly wanting to add. It is half-implemented in the codebase right now, but we got distracted by API design questions and never finished it.
I don't want every mutator to have to do this kind of error handling manually.
@@ -0,0 +1,38 @@ | |||
export class Subscribable< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also @arv just confirming there's nothing like this already in Replicache so we don't duplicate code?
* @param listener - The listener to subscribe to. | ||
* @returns A function to unsubscribe the listener. | ||
*/ | ||
addOnlineChangeListener = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about onOnline
and then we deprecate onOnlineChange
.
); | ||
} | ||
|
||
this.#onOnlineChange = onOnlineChange; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change but it is so simple to update I am supportive.
There was a usability issue with the online status with Zero. React doesn't rerender when Zero's online property updates. This proposes an API,
onOnline
, to make it easier to listen for updates to this. And an accompanying hook in React/SolidJS,useZeroOnline
.