Skip to content

Commit

Permalink
Merge pull request #1007 from BoussonKarel/patch-1
Browse files Browse the repository at this point in the history
fix: bugs in trackedFunction docs
  • Loading branch information
NullVoxPopuli authored Sep 26, 2023
2 parents 6887724 + 9094cbe commit 172c286
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ember-resources/src/util/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,21 @@ import { resource } from '../core/function-based';
* ```js
* import Component from '@glimmer/component';
* import { tracked } from '@glimmer/tracking';
* import { resourceFactory, use } from 'ember-resources';
* import { resourceFactory, resource, use } from 'ember-resources';
* import { trackedFunction } from 'ember-resources/util/function';
* import { on } from '@ember/modifier';
*
* const Request = resourceFactory((idFn) => {
* return trackedFunction(this, async () => {
* let id = idFn();
* let response = await fetch(`https://swapi.dev/api/people/${id}`);
* let data = await response.json();
* return resource(({use}) => {
* let trackedRequest = use(trackedFunction(async () => {
* let id = idFn();
* let response = await fetch(`https://swapi.dev/api/people/${id}`);
* let data = await response.json();
*
* return data; // { name: 'Luke Skywalker', ... }
* return data; // { name: 'Luke Skywalker', ... }
* }));
*
* return trackedRequest;
* });
* });
*
Expand Down

0 comments on commit 172c286

Please sign in to comment.