diff --git a/.changeset/five-hounds-smell.md b/.changeset/five-hounds-smell.md
new file mode 100644
index 000000000..d1232d3dc
--- /dev/null
+++ b/.changeset/five-hounds-smell.md
@@ -0,0 +1,23 @@
+---
+"ember-resources": patch
+---
+
+Fix an issue with a new (not yet used feature) where Resources could directly return a `Cell`, and it would have its `.current` method automatically called when resolving the value of a Resource.
+
+```gjs
+import { resource, cell } from 'ember-resources';
+
+export const Now = resource(({ on }) => {
+ const now = cell(Date.now());
+ const timer = setInterval(() => now.set(Date.now()));
+
+ on.cleanup(() => clearInterval(timer));
+
+ return now;
+});
+
+
+
+ It is:
+
+```
diff --git a/ember-resources/src/core/function-based/manager.ts b/ember-resources/src/core/function-based/manager.ts
index 6fa0ffbee..03851b565 100644
--- a/ember-resources/src/core/function-based/manager.ts
+++ b/ember-resources/src/core/function-based/manager.ts
@@ -8,6 +8,7 @@ import { invokeHelper } from '@ember/helper';
import { capabilities as helperCapabilities } from '@ember/helper';
import { dependencySatisfies, importSync, macroCondition } from '@embroider/macros';
+import { Cell } from '../../util/cell';
import { INTERNAL } from './types';
import type {
@@ -130,6 +131,10 @@ class FunctionResourceManager {
return maybeValue();
}
+ if (maybeValue instanceof Cell) {
+ return maybeValue.current;
+ }
+
return maybeValue;
}
diff --git a/ember-resources/src/util/cell.ts b/ember-resources/src/util/cell.ts
index bc9e03ca0..12596c238 100644
--- a/ember-resources/src/util/cell.ts
+++ b/ember-resources/src/util/cell.ts
@@ -17,7 +17,7 @@ interface GlintRenderable {
toHTML(): string;
}
-class Cell implements GlintRenderable {
+export class Cell implements GlintRenderable {
@tracked declare current: Value;
toHTML(): string {
diff --git a/test-app/tests/core/function-resource/rendering-test.gts b/test-app/tests/core/function-resource/rendering-test.gts
index dc642d7dd..8c0f56ad6 100644
--- a/test-app/tests/core/function-resource/rendering-test.gts
+++ b/test-app/tests/core/function-resource/rendering-test.gts
@@ -6,11 +6,19 @@ import { clearRender, render, settled } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
-import { resource, use } from 'ember-resources';
+import { resource, use, cell } from 'ember-resources';
module('Utils | (function) resource | rendering', function (hooks) {
setupRenderingTest(hooks);
+ test(`returning a cell renders the cell's value`, async function (assert) {
+ const StuckClock = resource(() => cell(2));
+
+ await render({{StuckClock}});
+
+ assert.dom().hasText('2');
+ });
+
module('lifecycle', function () {
module('direct rendering', function () {
test('when consuming tracked data', async function (assert) {
@@ -345,7 +353,7 @@ module('Utils | (function) resource | rendering', function (hooks) {
assert.verifySteps(['destroy 0']);
});
- test('when gated by an if and conusming tracked data', async function (assert) {
+ test('when gated by an if and consuming tracked data', async function (assert) {
// reminder that destruction is async
let steps: string[] = [];
let step = (msg: string) => {