v1.0.0 - 2024-07-13
🎉 Version 1.0! No new features, but after much procrastination I'm confident that Phetch is stable and ready to release properly.
- BREAKING CHANGE:
SetArgAsync
,RefetchAsync
, andTriggerAsync
no longer throw an exception if the query function fails, and instead return aQueryResult<T>
type which is either a success or failure.- This makes them safer to use as callbacks in your Blazor components, but in most cases you should still use the non-async versions (
SetArg
,Refetch
,Trigger
). - To migrate code using these methods without changing the functionality, simply replace
await query.SetArgAsync(..)
with(await query.SetArgAsync(..)).GetOrThrow()
.
- This makes them safer to use as callbacks in your Blazor components, but in most cases you should still use the non-async versions (
- BREAKING CHANGE: Removed the old
Mutation<TArg>
class which was previously marked obsolete. UseQuery<TArg, Unit>
instead, which is equivalent. - BREAKING CHANGE: Removed the old
Skip
option on<UseEndpoint/>
, which was previously marked obsolete. UseAutoFetch
instead.
v0.7.1 - 2024-06-08
- New
RefetchInterval
option on queries to automatically re-fetch a query on a fixed interval.
- Some minor improvements to type definitions for
Query
methods (non-breaking). - Improved docs for async
Query
methods.
- More tests.
v0.7.0 - 2024-05-04
- The non-generic
QueryOptions
class can now be implicitly cast toQueryOptions<TArg, TResult>
. - New
DataChanged
event for queries, which is triggered whenever theData
property changes.
- BREAKING CHANGE: If a query succeeds and then fails on a refetch,
query.Data
now returnsnull
/default
, instead of the old data. Also,query.LastData
now returns the data from the last successful request (even if the arg was different) instead ofnull
/default
. QueryOptions.OnSuccess
is now called when a cached result is returned (unless it's stale). Note:EndpointOptions.OnSuccess
is unchanged, and still won't be called when a cached result is returned.
- More tests.
- Sample project improvements.
v0.6.0 - 2023-12-01
- New DocFX site for documentation
- Updated docs for CacheTime and StaleTime
- If you're targeting .NET 8, you'll now have proper hot reload support in components containing
<UseEndpoint/>
or<ObserveQuery/>
. This isn't specific to this version of Phetch, but worth mentioning anyway. UseEndpointInfinite.LoadNextPageAsync
now returns the result of the next page query, or throws if the next page can't be loaded yet (e.g., the last page failed).
- BREAKING CHANGE:
<ObserveQuery/>
no longer detaches queries automatically when disposed. To keep the same behaviour as before, setDetachWhenDisposed="true"
, or explicitly callquery.Dispose()
in theDispose
method of your component. - BREAKING CHANGE: Changed the function signature for the
GetNextPageArg
option of<UseEndpointInfinite/>
. - Removed the
<UseMutationEndpoint/>
component that was previously marked as[Obsolete]
.
- Fixed events not being properly unsubscribed when
<ObserveQuery/>
was disposed. - Fixed failed queries in cache not automatically re-fetching if they have previously succeeded.
- Lots more tests.
- Upgraded sample projects to .NET 8
v0.5.1 - 2023-07-14
- Queries now trigger a
StateChanged
event when they begin fetching. This makes the behavior a bit more predictable when using endpoints across multiple components. - Improved docs for
<ObserveQuery/>
.
- New
onSuccess
andonFailure
callback parameters forquery.Trigger()
methods, which get called when the query succeeds or fails, respectively. Thanks to @Paxol for suggesting this.
v0.5.0 - 2023-06-19
- BREAKING CHANGE: Removed public constructors for
Query
that were previously deprecated. - BREAKING CHANGE: Renamed
MutationEndpoint<T>
toResultlessEndpoint<T>
for better consistency. The oldMutationEndpoint<T>
has been marked as obsolete, and left in temporarily to make migration easier. Also removedMutation<T>
and<UseMutationEndpoint/>
, which can safely be replaced withQuery<T, Unit>
and<UseEndpoint/>
. - Moved some of the methods on
Query<T>
to extension methods, so that they would also work on the equivalentQuery<Unit, T>
class. - Lots of improvements to documentation and samples.
- More tests.
- Fixed some issues that arise when
Skip
andArg
parameters ofUseEndpoint
are changed simultaneously.
v0.4.0 - 2023-03-06
Endpoint.TryGetCachedResult
method, to retrieve a cached result synchronously for the given query argument.- New
IQuery
andIQuery<TArg, TResult>
interfaces, to help with testing or writing methods that operate on queries. - Lots more tests (currently 96% line coverage in
Phetch.Core
). - Lots of improvements to the sample projects (in samples).
- Public constructors for
Query
are now deprecated, because they serve very little value since adding Endpoints. Instead, just create an endpoint and call.Use()
. These constructors will be removed in a future release.
- Exceptions in
OnSuccess
/OnFailure
callbacks are now caught, instead of being incorrectly treated as a query failure.
v0.3.1 - 2022-11-21
- Lots more tests
Query
andEndpoint
classes now have a publicOptions
property to read the options that were passed to them.Query
now has aCurrentQuery
property to get theFixedQuery
that it is currently observing.- New
KeySelector
option to customize the value used for caching query arguments. - Support for infinite
StaleTime
by passing a negative value
RefetchAsync
and similar methods now return the result data from the query.
- BREAKING CHANGE:
Query.Refetch
now throws an exception if it is un-initialized, instead of failing silently. null
can now be used as a query argument.- Fixed bug where large
StaleTime
values (e.g., `TimeSpan.MaxValue) would cause an overflow.
v0.3.0 - 2022-11-13
- New parameter for
UpdateQueryData
to optionally insert a new cache entry if one doesn't already exist for the given argument. - Read-only
Arg
property onQuery
class, to access the last argument passed toSetArg
. - Option to pass child content directly to
<ObserveQuery/>
, so that only the child content is re-rendered when the query updates. When using this method, there is no need to pass theOnChanged="StateHasChanged"
parameter. - New
RetryHandler
option for endpoints and queries, to control whether and how the query retries upon failure. - New non-generic
EndpointOptions
andQueryOptions
classes, which can be used to share "default" settings between endpoints and queries. - New experimental
<UseEndpointInfinite/>
component for creating "infinite scroll" features. To use this, add@using Phetch.Blazor.Experimental
to your_Imports.razor
.
- BREAKING CHANGE: Removed the return value from
UpdateQueryData
- BREAKING CHANGE: Removed the
arg
parameter fromInvalidateWhere
. Instead, use theArg
property of the query. - Various improvements to documentation and sample projects.
v0.2.0 - 2022-08-18
- New
GetCachedQuery
method onEndpoint
to look up a cache entry.- The returned cache entry can also be invalidated with
Invalidate()
, or have its data updated withUpdateQueryData(...)
.
- The returned cache entry can also be invalidated with
- New overload for
UpdateQueryData
which takes a function of the old query data. - New
DefaultStaleTime
option forEndpoint
, which sets the stale time when no value is passed toUse
. - New synchronous
Prefetch()
method onEndpoint
, which doesn't return a Task.
- BREAKING CHANGE: Rename
QuerySuccessContext
andQueryFailureContext
toQuerySuccessEventArgs
andQueryFailureEventArgs
. - Various improvements to documentation and sample projects.
- Query functions that throw
OperationCancelledException
instead ofTaskCancelledException
will now be caught correctly after cancelling a query.
v0.1.2 - 2022-08-06
- Enabled source link, debug symbols, and deterministic builds.
- Added null checks to public methods, so they now throw
ArgumentNullException
ifnull
is passed where it shouldn't be.
- Set up CI deployments with GitHub actions
v0.1.1 - 2022-08-01
Query.Cancel()
now causes the query state to change immediately, rather than waiting for the query function to throw aTaskCanceledException
.
- Added a
PrefetchAsync
method toEndpoint
, which can be used to fetch data ahead of time. - Added new overloads for
Endpoint
constructors which don't require aCancellationToken
to be passed. - Added a
Trigger()
method toQuery<T>
that doesn't require an argument to be passed.
- Fixed a bug which caused
Cancel()
to result in a query error if the cancellation didn't happen synchronously.
v0.1.0 - 2022-07-26
This release removes the concept of mutations as the previously existed, and instead combines the previous functionality of mutations into the Query
class. This is a very significant change, but future releases should contain far fewer breaking changes.
- Removes the existing
Mutation
andMutationEndpoint
classes.- You can now just use the standard
Query
classes, and callTrigger
instead ofSetArg
to get the same functionality.
- You can now just use the standard
- Replaces
QueryEndpoint
withEndpoint
,ParameterlessEndpoint
, and 'MutationEndpoint` (depending on the shape of the query function). - Replaces
UseQueryEndpoint
withUseEndpoint
,UseParameterlessEndpoint
, and 'UseMutationEndpoint`. - Renames
SetParam
toSetArg
.
- Mutations now have all the same features as queries, including caching, cache updates/invalidation, and cancellation.
- Adds
OnSuccess
/OnFailure
options to both queries and endpoints. - Adds support for
CancellationToken
across the entire library. - Adds a
Skip
parameter toUseEndpoint
, for conditional fetching. - Lots of extra documentation.
- Fixes bugs involving the handling of out-of-order query returns.
- Fixes bugs causing double-fetching
- Fixes bugs causing unnecessary double-rendering of Blazor components.
- Adds lots of automated tests.
- Significantly improves the README.