Skip to content
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

Wire up "payment channel updated" events stream to demo #1801

Merged
merged 6 commits into from
Oct 12, 2023

Conversation

geoknee
Copy link
Contributor

@geoknee geoknee commented Oct 3, 2023

Updates the demo to hook the UI into events rather than using timeouts + polling.

@netlify
Copy link

netlify bot commented Oct 3, 2023

Deploy Preview for nitro-payment-demo ready!

Name Link
🔨 Latest commit 09617eb
🔍 Latest deploy log https://app.netlify.com/sites/nitro-payment-demo/deploys/6524075bb60acb0008cbf157
😎 Deploy Preview https://deploy-preview-1801--nitro-payment-demo.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines +147 to +153
// It's possible the channel updated before we registered the handler above, so
// query the channel once now to get the latest information:

setPaymentChannelInfo(
await nitroClient?.GetPaymentChannel(result.ChannelId)
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a pretty common issue and makes for pretty bad DX. Perhaps a smarter event queue could be used in place of an event emitter.

@@ -182,25 +177,17 @@ export default function App() {
nitroClient,
(progress) => {
setDownloadProgress(progress);
updateChannelInfo(paymentChannelInfo.ID);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the nub of the change. Instead of reaching out with http queries each time we think the channel will have changed, we just listen for events being pushed to us. This should cut down on a bit of latency, I think (round trip vs half round trip).

@geoknee geoknee marked this pull request as draft October 3, 2023 17:02
@geoknee geoknee changed the base branch from fildev-payment-client to main October 9, 2023 13:49
@geoknee geoknee force-pushed the ts-payment-channel-updated-events-demo branch from 58e67fb to 7c6e3f5 Compare October 9, 2023 13:50
@netlify
Copy link

netlify bot commented Oct 9, 2023

Deploy Preview for nitrodocs ready!

Name Link
🔨 Latest commit 09617eb
🔍 Latest deploy log https://app.netlify.com/sites/nitrodocs/deploys/6524075b86f6a70008fd4de9
😎 Deploy Preview https://deploy-preview-1801--nitrodocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@geoknee geoknee marked this pull request as ready for review October 9, 2023 19:28
@lalexgap lalexgap merged commit 33b9e85 into main Oct 12, 2023
10 checks passed
@geoknee geoknee deleted the ts-payment-channel-updated-events-demo branch October 12, 2023 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants