Skip to content

Commit

Permalink
Optimize async functions in GenieClass
Browse files Browse the repository at this point in the history
  • Loading branch information
valkjsaaa committed Nov 22, 2023
1 parent 774b599 commit 19e7376
Show file tree
Hide file tree
Showing 4 changed files with 839 additions and 717 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16.17.0"
node-version: "20.9.0"
- run: npm ci
# - run: npm test
- uses: JS-DevTools/npm-publish@v2
Expand Down
11 changes: 8 additions & 3 deletions lib/__test__/example_descriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,13 @@ export class Order extends DataClass {
static _current: Order = undefined;

@GenieFunction("Get the current order")
static current(): Order {
static async current(): Promise<Order> {
if (this._current === undefined) {
this._current = Order.CreateObject({
orderId: (Order.all().length + 1).toString(),
dateTime: DateTime.fromDate(new Date()),
foods: [],
restaurant: Restaurant.current(),
restaurant: await Restaurant.current(),
});
}
return this._current;
Expand Down Expand Up @@ -582,7 +582,12 @@ export class Restaurant extends DataClass {
}

@GenieFunction("Get the current restaurant")
static current(): Restaurant {
static async current(): Promise<Restaurant> {
await new Promise((resolve) => {
setTimeout(() => {
resolve(void 0);
}, 10);
});
return this.all()[0];
}

Expand Down
Loading

0 comments on commit 19e7376

Please sign in to comment.