Skip to content

Releases: NullVoxPopuli/ember-resources

v7.0.2-ember-resources: Merge pull request #1131 from NullVoxPopuli/release-preview

18 Jun 21:00
89306e8
Compare
Choose a tag to compare

Release (2024-06-18)

ember-resources 7.0.2 (patch)

🐛 Bug Fix

  • ember-resources, test-app
    • #1135 Fix issue where, in some situations, the immediate-invoker helper manager (used when you use resourceFactory) was not correctly destroying the previous instance of a resource (such as when args change)) (@NullVoxPopuli)

Committers: 1

v7.0.1-ember-resources: Merge pull request #1113 from NullVoxPopuli/release-preview

03 May 20:44
7d0507a
Compare
Choose a tag to compare

Release (2024-05-03)

ember-resources 7.0.1 (patch)

🐛 Bug Fix

📝 Documentation

🏠 Internal

Committers: 1

v7.0.0: focus ember-resources, move utils to reactiveweb

11 Jan 20:42
d084369
Compare
Choose a tag to compare

Release (2024-01-11)

everything removed in this release is a utility, and the code + tests have been copied exactly to reactiveweb: https://github.com/universal-ember/reactiveweb -- which is also a pay-as-you-go library.

ember-resources 7.0.0 (major)

💥 Breaking Change

🚀 Enhancement

  • @nullvoxpopuli/estimate-bytes, docs, ember-resources, test-app
    • #1097 Infra modernization, support both built in types from ember-source, as well as the types from DefinitelyTyped (@NullVoxPopuli)
  • Other
  • ember-resources
  • test-app
  • @nullvoxpopuli/estimate-bytes, ember-resources, test-app

🐛 Bug Fix

  • ember-resources, test-app

📝 Documentation

🏠 Internal

Committers: 1

v6.5.1-ember-resources: Merge pull request #1093 from NullVoxPopuli/release-preview-v6

09 Jan 22:53
5aad799
Compare
Choose a tag to compare

Release (2024-01-09)

ember-resources 6.5.1 (patch)

🐛 Bug Fix

🏠 Internal

Committers: 1

v6.5.0-ember-resources: Merge pull request #1073 from NullVoxPopuli/release-preview

08 Jan 23:36
f839795
Compare
Choose a tag to compare

Release (2024-01-08)

ember-resources 6.5.0 (minor)

🚀 Enhancement

📝 Documentation

🏠 Internal

  • test-app
    • #1074 [v6]: Ensure that the available API for v7 does not throw deprecations (@NullVoxPopuli)

Committers: 1

v6.4.3-ember-resources: Merge pull request #1063 from NullVoxPopuli/release-preview

05 Jan 23:05
ef48829
Compare
Choose a tag to compare

Release (2024-01-05)

ember-resources 6.4.3 (patch)

🐛 Bug Fix

  • ember-resources, test-app
  • ember-resources

🏠 Internal

Committers: 4

ember-resources@6.4.2

20 Oct 06:23
Compare
Choose a tag to compare

Patch Changes

  • #1019 d63d7b7 Thanks @wagenet! - The keepLatest utility previously incorrectly had a | undefined type for the return value.
    That's been removed.

    | undefined is still a valid type if the passed value is possibly | undefined.
    This made the | undefined on keepLatest redundant.

ember-resources@6.4.1

20 Oct 04:38
1c1ad1c
Compare
Choose a tag to compare

Patch Changes

  • #1011 606ba4b Thanks @NullVoxPopuli! - trackedFunction: Fix timing issue where updating tracked data consumed in trackedFunction would not re-cause the isLoading state to become true again.

    Resolves #1010

ember-resources@6.4.0

13 Aug 17:40
ae1e239
Compare
Choose a tag to compare

Minor Changes

  • #975 1a964f1 Thanks @NullVoxPopuli! - trackedFunction can now be composed just like regular resources.

    The function body still auto-tracks and will update within consuming resource appropriately.

    Example
    const Person = resourceFactory((maybeIdFn) => {
      return resource(({ use }) => {
        let request = use(
          trackedFunction(async () => {
            let id = typeof maybeIdFn === "function" ? maybeIdFn() : maybeIdFn;
            let response = await fetch(`https://github.com/gitapi/users/${id}`);
            return response.json();
          })
        );
    
        // `use` returns a ReadonlyCell where `.current`
        // is the State of trackedFunction.
        return () => request.current;
      });
    });

    Usage examples:

    <template>
        {{#let (Person 1) as |request|}}
          {{#if request.isLoading}}
             ... loading ...
          {{/if}}
    
          {{#if request.value}}
    
          {{/if}}
        {{/let}}
    </template>
    An async doubler
    const Doubled = resourceFactory((num: number) => {
      return resource(({ use }) => {
        let doubler = use(trackedFunction(async () => num * 2));
    
        // Since current is the "State" of `trackedFunction`,
        // accessing .value on it means that the overall value of
        // `Doubled` is the eventual return value of the `trackedFunction`
        return () => doubler.current.value;
      });
    });
    
    // Actual code from a test
    class State {
      @tracked num = 2;
    }
    
    let state = new State();
    
    setOwner(state, this.owner);
    
    await render(<template><out>{{Doubled state.num}}</out></template>);
    Example with arguments

    Imagine you want to compute the hypotenuse of a triangle,
    but all calculations are asynchronous (maybe the measurements exist on external APIs or something).

    // Actual code from a test
    type NumberThunk = () => number;
    
    const Sqrt = resourceFactory((numFn: NumberThunk) =>
      trackedFunction(async () => {
        let num = numFn();
    
        return Math.sqrt(num);
      })
    );
    
    const Squared = resourceFactory((numFn: NumberThunk) =>
      trackedFunction(async () => {
        let num = numFn();
    
        return Math.pow(num, 2);
      })
    );
    
    const Hypotenuse = resourceFactory((aFn: NumberThunk, bFn: NumberThunk) => {
      return resource(({ use }) => {
        const aSquared = use(Squared(aFn));
        const bSquared = use(Squared(bFn));
        const c = use(
          Sqrt(() => {
            return (aSquared.current.value ?? 0) + (bSquared.current.value ?? 0);
          })
        );
    
        // We use the function return because we want this property chain
        // to be what's lazily evaluated -- in this example, since
        // we want to return the hypotenuse, we don't (atm)
        // care about loading / error state, etc.
        // In real apps, you might care about loading state though!
        return () => c.current.value;
    
        // In situations where you care about forwarding other states,
        // you could do this
        return {
          get value() {
            return c.current.value;
          },
          get isLoading() {
            return (
              a.current.isLoading || b.current.isLoading || c.current.isLoading
            );
          },
        };
      });
    });

ember-resources@6.3.1

26 Jul 02:39
d98bc19
Compare
Choose a tag to compare

Patch Changes

  • #960 77d54e6 Thanks @NullVoxPopuli! - Resolves: #958

    used Resources can now be immediately returned from other resources.

    const Clock = resource(({ use }) => {
      return use(Instant({ intervalMs: 1000 });
    });
    
    const Stopwatch = resource(({ use }) => {
      return use(Instant({ intervalMs: 0 });
    });
    
    <template>
        <time>{{Clock}}</time>
    
        MS since Epoch: {{Stopwatch}}
    </template>