Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
ember-resources@6.0.0
Major Changes
#715
e8155b2
Thanks @NullVoxPopuli! - Drop support for TypeScript < 4.8 in order to support Glint.#778
901ae9a
Thanks @NullVoxPopuli! - Themap
utility resource has changed its first type-argument for better inference.The utility already supported inference, so this change should not impact too many folks.
Migration and Reasoning
When explicit type-arguments were specified,
This is advantageous, because with
@tsconfig/ember
, the optionnoUncheckedIndexedAccess
is enabled by default. This is a great strictness / quality option to have enabled,
as arrays in javascript are mutable, and we can't guarantee that they don't change between
index-accesses.
However the
map
utility resource explicitly disallows the indicies to get out of syncwith the source
data
.But!, with
noUncheckedIndexedAccess
, you can only infer so much before TS goes the safe route,and makes the returned type
X | undefined
.For example, in these type-tests:
#815
54e2b50
Thanks @NullVoxPopuli! - TheRemoteData
resource now has the same state changes and semantics astrackedFunction
.Breaking Changes:
isResolved
is only true when the request succeeds. During migration, you may useisFinished
for previous behavior.#779
a471d9b
Thanks @NullVoxPopuli! -trackedFunction
has a new API and thus a major version release is required.Work by @lolmaus
tl;dr: the breaking changes:
isResolved
is only true on successother changes:
trackedFunction
is a wrapper aroundember-async-data
'sTrackedAsyncData
ember-async-data
will need to be installed in the consumer's app to continue usingtrackedFunction
This keeps installs minimal for folks using ember-resources and are not using
trackedFunction
NOTE:
trackedFunction
is an example utility of how to use auto-tracking with function invocation,and abstract away the various states involved with async behavior. Now that the heavy lifting is done by
ember-async-data
,trackedFunction
is now more of an example of how to integrated existing tracked utilities in to resources.Migration
Previously, the state's
isResolved
property ontrackedFunction
wastrue
on both success and error.now,
isFinished
can be used instead.isResolved
is now only true when the function runs to completion without error, aligning with the semantics of promises.Previously,
trackedFunction
could take an initial value for its second argument.This has been removed, as initial value can be better maintained and made more explicit
in user-space. For example:
Or, in a template:
Or, in gjs/strict mode:
#785
66cee0e
Thanks @NullVoxPopuli! - The import pathember-resources/util/function-resource
has been removed,as all the relevent exports have been available from
ember-resources
since v5.Minor Changes
#797
18adb86
Thanks @NullVoxPopuli! - Add link() and @link, importable fromember-resources/link
.NOTE: for existing users of
ember-resources
, this addition has no impact on your bundle.Example property usage
Example inline usage
This abstracts away the following boilerplate:
#778
f841a98
Thanks @NullVoxPopuli! - Use strictest possible settings with TypeScript so that consumers can't be stricter than this library#776
a99793e
Thanks @NullVoxPopuli! - Glint is now supported starting with 1.0.0-beta.3#818
feeb2db
Thanks @NullVoxPopuli! - RemoteData now checks the response's Content-Type header to decide whether to convert to JSON or Text#794
8989bbb
Thanks @NullVoxPopuli! - New Utils: UpdateFrequency and FrameRateNOTE: for existing users of
ember-resources
, this addition has no impact on your bundle.FrameRate
Utility that uses requestAnimationFrame to report
how many frames per second the current monitor is
rendering at.
The result is rounded to two decimal places.
UpdateFrequency
Utility that will report the frequency of updates to tracked data.
NOTE: the function passed to UpdateFrequency may not set tracked data.
Patch Changes
#769
abaad4a
Thanks @GreatWizard! - fix typo in map error message when checking if every datum is an object#828
24b540e
Thanks @NullVoxPopuli! - ember-async-data@v1 is out, so since we're just now using it, that can be the minimum version.NOTE:
ember-async-data
's minimum ember-source is 4.8, so while things might work with earlier ember-source's it's not guaranteed.#826
50ad1ba
Thanks @NullVoxPopuli! - When using RemoteData, isError should be true when the http status code is >= 400. Resolves RemoteData: if status is >= 400, isError should be true #825".Previously, when you had a JSON response with 404 status code,
isError
would be false instead of true.#865
6df54b1
Thanks @NullVoxPopuli! - Add the last v4 LTS, ember-source v4.12, to the test matrix#806
00e8f2f
Thanks @sergey-zhidkov! -trackedTask
must return correct last value.Fixes the issue described at
trackedTask
returns last task value if current task value isnull
orundefined
#793If the task was called multiple times and the last returned value was null or undefined,
then trackedTask will return the previous value instead of the current one.
#838
acbf03d
Thanks @NullVoxPopuli! - Fixes #835 - resolves regression introduced by PR: #808 which aimed to correctly return the previous task instance's value if the current task hasn't finished yet. The regression described by Incorrect value returned when last task was dropped #835 was that if a task in cancelled (e.g.: dropped), it is considered finished, and that canceled task's value would be used instead of the last compuleted task. In normal ember-concurrency APIs, this is abstracted over via the.lastSuccessful
property on theTaskProperty
. The goal of the.value
ontrackedTask
is to mimic the property chain:taskProperty.lastSuccessful?.value
.#830
0767c08
Thanks @NullVoxPopuli! - Support TS 5.0#868
b6f78c9
Thanks @NullVoxPopuli! - Test against ember-concurrency@v3, and add it as an allowed peerDepnedency