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

[🐴] requestPollInterval for event bus #3914

Merged
merged 1 commit into from
May 8, 2024
Merged

Conversation

estrattonbailey
Copy link
Member

Different screens and views will require different poll intervals. Instead of implicitly setting and reverting poll interval directly for each case, this PR introduces requestPollInterval. This method maintains a reference to all requested intervals, and if the event bus is in the Ready state, we apply the lowest poll interval requested.

Components that request a poll interval will need to ensure they withdraw the request when unmounting, to requestPollInterval returns a function to do so.

const events = useMessagesEventBus()

events.trailConvo(convoId, events => console.log(events))

useFocusEffect(
  useCallback(() => {
    const cleanup = events.requestPollInterval(1e3)
    return () => { cleanup() }
  }, [events])
)

Copy link

render bot commented May 8, 2024

Copy link

github-actions bot commented May 8, 2024

Old size New size Diff
6.89 MB 6.89 MB 357 B (0.00%)

@estrattonbailey estrattonbailey changed the title Move to requestPollInterval handling [🐴] requestPollInterval for event bus May 8, 2024
Copy link
Member

@mozzius mozzius left a comment

Choose a reason for hiding this comment

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

beautiful

@estrattonbailey estrattonbailey merged commit 7d06fb9 into main May 8, 2024
6 checks passed
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