Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v6]: Deprecate util/* imports #1070

Merged
merged 4 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ember-resources/src/util/debounce.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
import { tracked } from '@glimmer/tracking';
import { deprecate } from '@ember/debug';

import { resource } from '../core';

deprecate(
`importing from 'ember-resources/util/debounce' is deprecated and will be removed in ember-resources@v7. ` +
`The exact same code and support is available at https://github.com/universal-ember/reactiveweb. ` +
`\`pnpm add reactiveweb\` and then \` import { debounce } from 'reactiveweb/debounce';\`. ` +
`See also: https://github.com/NullVoxPopuli/ember-resources/issues/1061`,
false,
{
id: `ember-resources.util.debounce`,
until: `7.0.0`,
for: `ember-resources`,
url: `https://reactive.nullvoxpopuli.com/functions/debounce.debounce.html`,
since: {
available: '6.4.4',
enabled: '6.4.4',
},
},
);

class TrackedValue<T> {
@tracked value: T | undefined;
}
Expand Down
20 changes: 19 additions & 1 deletion ember-resources/src/util/ember-concurrency.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable ember/no-get */

// typed-ember has not publihsed types for this yet
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { getValue } from '@glimmer/tracking/primitives/cache';
import { deprecate } from '@ember/debug';
import { assert } from '@ember/debug';
// typed-ember has not publihsed types for this yet
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand All @@ -18,6 +18,24 @@ import { DEFAULT_THUNK, normalizeThunk } from '../core/utils';

import type { Cache } from '../core/types';

deprecate(
`importing from 'ember-resources/util/ember-concurrency' is deprecated and will be removed in ember-resources@v7. ` +
`The exact same code and support is available at https://github.com/universal-ember/reactiveweb. ` +
`\`pnpm add reactiveweb\` and then \` import { task, trackedTask } from 'reactiveweb/ember-concurrency';\`. ` +
`See also: https://github.com/NullVoxPopuli/ember-resources/issues/1061`,
false,
{
id: `ember-resources.util.trackedTask`,
until: `7.0.0`,
for: `ember-resources`,
url: `https://reactive.nullvoxpopuli.com/functions/ember_concurrency.task.html`,
since: {
available: '6.4.4',
enabled: '6.4.4',
},
},
);

/**
* <div class="callout note">
*
Expand Down
20 changes: 20 additions & 0 deletions ember-resources/src/util/fps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
import { deprecate } from '@ember/debug';

import { cell, resource, resourceFactory } from '../index';

deprecate(
`importing from 'ember-resources/util/fps' is deprecated and will be removed in ember-resources@v7. ` +
`The exact same code and support is available at https://github.com/universal-ember/reactiveweb. ` +
`\`pnpm add reactiveweb\` and then \` import { FrameRate, UpdateFrequency } from 'reactiveweb/fps';\`. ` +
`See also: https://github.com/NullVoxPopuli/ember-resources/issues/1061`,
false,
{
id: `ember-resources.util.fps`,
until: `7.0.0`,
for: `ember-resources`,
url: `https://reactive.nullvoxpopuli.com/modules/fps.html`,
since: {
available: '6.4.4',
enabled: '6.4.4',
},
},
);

/**
* <div class="callout note">
*
Expand Down
19 changes: 19 additions & 0 deletions ember-resources/src/util/function.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
import { tracked } from '@glimmer/tracking';
import { deprecate } from '@ember/debug';
import { assert } from '@ember/debug';
import { associateDestroyableChild, destroy, isDestroyed, isDestroying } from '@ember/destroyable';

import { TrackedAsyncData } from 'ember-async-data';

import { resource } from '../core/function-based';

deprecate(
`importing from 'ember-resources/util/function' is deprecated and will be removed in ember-resources@v7. ` +
`The exact same code and support is available at https://github.com/universal-ember/reactiveweb. ` +
`\`pnpm add reactiveweb\` and then \` import { trackedFunction } from 'reactiveweb/function';\`. ` +
`See also: https://github.com/NullVoxPopuli/ember-resources/issues/1061`,
false,
{
id: `ember-resources.util.function`,
until: `7.0.0`,
for: `ember-resources`,
url: `https://reactive.nullvoxpopuli.com/functions/function.trackedFunction.html`,
since: {
available: '6.4.4',
enabled: '6.4.4',
},
},
);

/**
* <div class="callout note">
*
Expand Down
19 changes: 19 additions & 0 deletions ember-resources/src/util/helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-ignore
import { getValue } from '@glimmer/tracking/primitives/cache';
import { deprecate } from '@ember/debug';
// @ts-ignore
import { invokeHelper } from '@ember/helper';

Expand All @@ -10,6 +11,24 @@ import type ClassBasedHelper from '@ember/component/helper';
import type { FunctionBasedHelper } from '@ember/component/helper';
import type { HelperLike } from '@glint/template';

deprecate(
`importing from 'ember-resources/util/helper' is deprecated and will be removed in ember-resources@v7. ` +
`The exact same code and support is available at https://github.com/universal-ember/reactiveweb. ` +
`\`pnpm add reactiveweb\` and then \` import { helper } from 'reactiveweb/helper';\`. ` +
`See also: https://github.com/NullVoxPopuli/ember-resources/issues/1061`,
false,
{
id: `ember-resources.util.fps`,
until: `7.0.0`,
for: `ember-resources`,
url: `https://reactive.nullvoxpopuli.com/functions/helper.helper.html`,
since: {
available: '6.4.4',
enabled: '6.4.4',
},
},
);

type Get<T, K, Otherwise = unknown> = K extends keyof T ? T[K] : Otherwise;

/**
Expand Down
36 changes: 28 additions & 8 deletions ember-resources/src/util/keep-latest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
import { deprecate } from '@ember/debug';

import { resource, resourceFactory } from '../core/function-based';

deprecate(
`importing from 'ember-resources/util/keep-latest' is deprecated and will be removed in ember-resources@v7. ` +
`The exact same code and support is available at https://github.com/universal-ember/reactiveweb. ` +
`\`pnpm add reactiveweb\` and then \` import { keepLatest } from 'reactiveweb/keep-latest';\`. ` +
`See also: https://github.com/NullVoxPopuli/ember-resources/issues/1061`,
false,
{
id: `ember-resources.util.keepLatest`,
until: `7.0.0`,
for: `ember-resources`,
url: `https://reactive.nullvoxpopuli.com/functions/keep_latest.keepLatest.html`,
since: {
available: '6.4.4',
enabled: '6.4.4',
},
},
);

const isEmpty = (x: undefined | unknown | unknown[]) => {
if (Array.isArray(x)) {
return x.length === 0;
Expand Down Expand Up @@ -77,16 +97,16 @@ export function keepLatest<Return = unknown>({ when, value: valueFn }: Options<R

if (when()) {
/**
* Initially, if we may as well return the value instead
* of the "previous" value is there is no previous yet.
*
* We check against undefined, because that's what
* `previous` is "initialized" to.
* Initially, if we may as well return the value instead
* of the "previous" value is there is no previous yet.
*
* We check against undefined, because that's what
`previous` is "initialized" to.
*
* And then we never enter this block again, because
* we will have previous values in future invocations of this
And then we never enter this block again, because
* we will have previous values in future invocations of this
* Formula.
*/
*/
if (previous === undefined && initial) {
initial = false;

Expand Down
19 changes: 19 additions & 0 deletions ember-resources/src/util/map.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import { tracked } from '@glimmer/tracking';
import { deprecate } from '@ember/debug';
import { assert } from '@ember/debug';

import { Resource } from '../core/class-based';

import type { Named, Positional } from '../core/types';

deprecate(
`importing from 'ember-resources/util/map' is deprecated and will be removed in ember-resources@v7. ` +
`The exact same code and support is available at https://github.com/universal-ember/reactiveweb. ` +
`\`pnpm add reactiveweb\` and then \` import { map } from 'reactiveweb/map';\`. ` +
`See also: https://github.com/NullVoxPopuli/ember-resources/issues/1061`,
false,
{
id: `ember-resources.util.map`,
until: `7.0.0`,
for: `ember-resources`,
url: `https://reactive.nullvoxpopuli.com/functions/map.map.html`,
since: {
available: '6.4.4',
enabled: '6.4.4',
},
},
);

/**
* Public API of the return value of the [[map]] resource.
*/
Expand Down
19 changes: 19 additions & 0 deletions ember-resources/src/util/remote-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { tracked } from '@glimmer/tracking';
import { deprecate } from '@ember/debug';
import { waitForPromise } from '@ember/test-waiters';

import { resource, resourceFactory } from '../core/function-based';
Expand All @@ -7,6 +8,24 @@ import type { ResourceAPI } from '../core/function-based';

type FetchOptions = Parameters<typeof fetch>[1];

deprecate(
`importing from 'ember-resources/util/remote-data' is deprecated and will be removed in ember-resources@v7. ` +
`The exact same code and support is available at https://github.com/universal-ember/reactiveweb. ` +
`\`pnpm add reactiveweb\` and then \` import { RemoteData } from 'reactiveweb/remote-data';\`. ` +
`See also: https://github.com/NullVoxPopuli/ember-resources/issues/1061`,
false,
{
id: `ember-resources.util.remoteData`,
until: `7.0.0`,
for: `ember-resources`,
url: `https://reactive.nullvoxpopuli.com/functions/remote_data.remoteData-1.html`,
since: {
available: '6.4.4',
enabled: '6.4.4',
},
},
);

/**
* @protected
*/
Expand Down
Loading