Releases: Jcparkyn/phetch
Releases · Jcparkyn/phetch
v1.0.0
🎉 Version 1.0! No new features, but after much procrastination I'm confident that Phetch is stable and ready to release properly.
Changed
- 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 (
Removed
- 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
v0.7.0
Added
- 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.
Changed
- 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.
Development
- More tests.
- Sample project improvements.
v0.6.0
Added
- 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).
Changed
- 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
- Fixed events not being properly unsubscribed when
<ObserveQuery/>
was disposed. - Fixed failed queries in cache not automatically re-fetching if they have previously succeeded.
Development
- Lots more tests.
- Upgraded sample projects to .NET 8
Full Changelog: v0.5.1...v0.6.0
v0.5.1
Changed
- 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/>
.
Added
- New
onSuccess
andonFailure
callback parameters forquery.Trigger()
methods, which get called when the query succeeds or fails, respectively. Thanks to @Paxol for suggesting this.
Full Changelog: v0.5.0...v0.5.1
v0.5.0
Changed
- 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
- Fixed some issues that arise when
Skip
andArg
parameters ofUseEndpoint
are changed simultaneously.
Full Changelog: v0.4.0...v0.5.0
v0.4.0
Added
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).
Changed
- 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.
Fixed
- Exceptions in
OnSuccess
/OnFailure
callbacks are now caught, instead of being incorrectly treated as a query failure.
v0.3.1
Added
- 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
Changed
RefetchAsync
and similar methods now return the result data from the query.
Fixed
- 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
Added
- 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
.
Changed
- 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
Added
- 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.
Changed
- BREAKING CHANGE: Rename
QuerySuccessContext
andQueryFailureContext
toQuerySuccessEventArgs
andQueryFailureEventArgs
. - Various improvements to documentation and sample projects.
Fixed
- Query functions that throw
OperationCancelledException
instead ofTaskCancelledException
will now be caught correctly after cancelling a query.