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

Feature: Live Refresh on View Orders #12

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Feature: Live Refresh on View Orders #12

wants to merge 14 commits into from

Conversation

Soleras3
Copy link
Owner

@Soleras3 Soleras3 commented Mar 20, 2023

Changes

  1. Refresh order data on View Orders every 5s
  2. Clear refresh loop when navigating away

Requires #9 because updated dependencies.

Purpose

Display updates to orders live as they happen. See: Shift3#12

Approach

This extends the view orders fetching mechanism to operate immediately, then every 5s, with a cleanup on useEffect return to cancel the loop when navigating away. The cleanup keeps only one update loop live while navigating around.

This only refreshes on the Live Orders screen. Live refresh could instead be on the app layer and delivered through prop drilling. An even cleaner choice would store order info in redux ala Shift3#9, a bonus issue I didn't have time for.

Testing Steps

Make a POST to live-mode while observing the View Orders screen.

Learning

I knew I needed to manage this update loop on "navigation in" and "navigation out", two explicit events in iOS. I knew useEffect was the hook-in point, and the API reference showed me how to cleanup.

[useEffect] should return a cleanup function with cleanup code that disconnects from that system.
Closes Shift3#12

@Soleras3 Soleras3 changed the title Live refresh Feature: Live Refresh on View Orders Mar 20, 2023
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.

Live Refresh
1 participant