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

Query state enum refactor + Fixing Cache Cleanup #3

Merged
merged 8 commits into from
Jul 29, 2023
Merged

Conversation

nicoburniske
Copy link
Member

@nicoburniske nicoburniske commented Jul 28, 2023

Relatively large refactor to address #2

  • Boolean signals inside of Query are now replaced with QueryState enum. Stale is intentionally not a state, and is instead a derived signal inside of QueryResult. This distinction allows for a query to be stale, while also having a descriptive state.
pub enum QueryState<V> {
    /// The initial state of a Query upon its creation.
    Created,

    /// Query is fetching for the first time.
    Loading,

    /// A Query is in the process of fetching, not being its first fetch.
    Fetching(QueryData<V>),

    /// The state indicating that a query has successfully completed a fetch operation.
    Loaded(QueryData<V>),

    /// The state indicating that a query has completed a fetch, but the fetched data is marked as invalid.
    Invalid(QueryData<V>),
}
  • Prevent effect nesting where possible in query_executor
  • Fix ensure_cache_cleanup to have non-duplicate timeouts, cleanups, and prevent disposing of Query while in use
    • Query Eviction from Cache will not happen until Query is no longer active.
  • Refactor QueryResult
    • Refetch is now Fn() + Clone instead of SignalSetter<()>
    • QueryResult<V> now contains a QueryState<V>
    • Removed Signal for updated_at
  • Removed QueryClient::get_query_data due to inconsistent behavior.

@nicoburniske nicoburniske merged commit 4075c2f into main Jul 29, 2023
@nicoburniske nicoburniske deleted the enum_refactor branch July 29, 2023 17:18
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.

None yet

1 participant