Skip to content

v0.2.0

Compare
Choose a tag to compare
@nicoburniske nicoburniske released this 29 Jul 17:52
· 90 commits to main since this release

Changes

New version based on introduction of QueryState<V> enum

Fix premature Query eviction from cache

A Query will only be evicted from cache once it are no longer being used, and the specified cache_time has elapsed since the last update. If a query gets marked for eviction, then receives an update as it's being used, it will not get evicted from cache and the timeout will restart.

New QueryState<V> enum

QueryResult now contains a signal for the current QueryState. This required a lot of changes internally, but only a few for users.

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.

Here's what it looks like:

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>),
}

Refactor of QueryResult

QueryResult now becomes QueryResult<V, impl RefetchFn>

RefetchFn is equivalent to Fn() + Clone

  • QueryResult::refetch is now Fn() + Clone instead of SignalSetter<()>
  • QueryResult now contains a QueryState<V>
  • Removed Signal for updated_at

Misc

  • Removed QueryClient::get_query_data due to inconsistent behavior.

What's Changed

New Contributors

Full Changelog: https://github.com/nicoburniske/leptos_query/commits/v0.2.0