Enums & supporting types

The smaller public types: enums, filters, the cache snapshot, the user-facing exception, and the observable contract.

RefetchOnMount#

RefetchOnMount#

public enum RefetchOnMount { Never, IfStale, Always }

Controls whether a keyed Execute that finds cached data also refetches in the background. A key with no cached data always fetches, regardless of this setting.

Value TypeDescription
Never 0Serve the cache and never refetch on mount. Invalidation still refetches.
IfStale 1Refetch in the background only when the data is older than the stale time.
Always 2Always refetch in the background, even when the data is still fresh.

RefetchType#

RefetchType#

public enum RefetchType { Active, All, None }

Which invalidated entries refetch immediately.

Value TypeDescription
Active 0Refetch entries that have live subscribers; entries without stay marked stale and refetch when a component next mounts on them.
All 1Refetch every matched entry, subscribed or not.
None 2Only mark entries stale; nothing refetches until the next mount.

InvalidateOptions#

InvalidateOptions#

public sealed class InvalidateOptions { public bool Exact { get; set; } public Func<QueryKey, bool>? Predicate { get; set; } public RefetchType RefetchType { get; set; } = RefetchType.Active; }

Options for DejaClient.InvalidateAsync. With Exact false (the default) the key matches by prefix — invalidating ["todos"] also invalidates ["todos", 1]. Predicate filters the matched keys further.

QueryFilter#

QueryFilter#

public sealed class QueryFilter { public bool Exact { get; set; } public Func<QueryKey, bool>? Predicate { get; set; } }

Narrows which entries a key matches in DejaClient.Remove and DejaClient.RefetchAsync. Prefix matching by default.

CacheEntryState#

CacheEntryState#

public sealed record CacheEntryState { public required bool HasData { get; init; } public DateTimeOffset? UpdatedAt { get; init; } public string? ErrorMessage { get; init; } public DateTimeOffset? ErrorUpdatedAt { get; init; } public bool IsInvalidated { get; init; } public bool IsFetching { get; init; } public int SubscriberCount { get; init; } }

A read-only snapshot of one cache entry, returned by DejaClient.GetState. Values are coherent with each other at the moment of the call and do not update afterwards. The cache inspectors on this site render exactly this record.

DisplayUserException#

DisplayUserException#

public class DisplayUserException : Exception { public string DisplayMessage { get; set; } public DisplayUserException() public DisplayUserException(string message) public DisplayUserException(string message, Exception ex) public DisplayUserException(string message, string internalMessage) public DisplayUserException(string message, string internalMessage, Exception ex) }

An exception whose DisplayMessage is safe — and intended — to be shown to the end user. Queries and mutations route it to the dedicated OnDisplayUserError callbacks in addition to the general error callbacks. The single-message constructors use the message for both display and Exception.Message; the two-message constructors separate the user-facing message from the internal one.

DejaObservable / IDejaObservable#

IDejaObservable#

public interface IDejaObservable { IDisposable Attach(Action listener); }

State that can notify exactly one owner when it changes — implemented by Query<T> and Mutation<T>, consumed by DejaComponentBase. Attach registers the sole listener and returns a handle whose disposal detaches it (idempotently); attaching while a listener is already registered throws InvalidOperationException. Deliberately single-listener rather than a multicast event: the one component that owns the state is the only thing that may be notified by it — which is what keeps two components holding their own queries from re-rendering each other.

DejaObservable#

public abstract class DejaObservable : IDejaObservable { public IDisposable Attach(Action listener) protected void NotifyChanged() }

Base implementation holding the single listener slot. Derived state calls NotifyChanged() once per state transition, after every property in the transition has been set; it is a safe no-op when nothing is attached. Extend it if you build custom observable state that a DejaComponentBase component should re-render for.