Skip to content

Commit 305846c

Browse files
Merge pull request #579 from NullVoxPopuli/fix-keepLatest-API
fix(keepLatest): use consistent condition name
2 parents c054c06 + 1f177cc commit 305846c

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

ember-resources/src/util/keep-latest.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface Options<T = unknown> {
2020
* keep the latest truthy value as the "return value"
2121
* (as determined by the `value` option's return value)
2222
*/
23-
until: () => boolean;
23+
when: () => boolean;
2424

2525
/**
2626
* A function who's return value will be used as the value
@@ -59,14 +59,14 @@ interface Options<T = unknown> {
5959
* }
6060
* ```
6161
*/
62-
export function keepLatest<Return = unknown>({ until, value: valueFn }: Options<Return>) {
62+
export function keepLatest<Return = unknown>({ when, value: valueFn }: Options<Return>) {
6363
return resource(() => {
6464
let previous: Return | undefined;
6565

6666
return () => {
6767
let value = valueFn();
6868

69-
if (until()) {
69+
if (when()) {
7070
return (previous = isEmpty(value) ? previous : value);
7171
}
7272

testing/ember-app/tests/utils/keep-latest/js-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module('Utils | keepLatest | js', function (hooks) {
2424
});
2525

2626
@use data = keepLatest({
27-
until: () => this.request.isLoading,
27+
when: () => this.request.isLoading,
2828
value: () => this.request.value,
2929
});
3030
}

testing/ember-app/tests/utils/keep-latest/rendering-test.gts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module('Utils | keepLatest | rendering', function (hooks) {
3333
render(<template>
3434
{{#let instance.request as |request|}}
3535
{{keepLatest (hash
36-
until=(fn passthrough request.isLoading)
36+
when=(fn passthrough request.isLoading)
3737
value=(fn passthrough request.value)
3838
)}}
3939
{{/let}}

0 commit comments

Comments
 (0)