biosustain / biosustain/potion-node

feat: implement async Item attributes

Open
#2 2 comments 0 reactions 0 assignees View on GitHub
Feature
Dominant language
TypeScript
Stars
8
Forks
5
PR merge metrics
No merged PRs in 30d

Description

A user should be able to mark certain `Item` properties as async and when references are resolved, these async properties should be skipped. Instead of resolving these async properties, their values should be promises that are not resolved unless their getter gets called.

Example:
```ts
import {Potion, Item} from 'potion';

const potion = new Potion();

@potion.registerAs('/bar')
class Bar extends Item {}

@potion.registerAs('/foo')
class Foo extends Item {
@async
bar: Bar;
}

const foo = Foo.first();

// At this point, the `bar` reference is not resolved
foo.then((item) => {
// Now Potion will resolve the `bar` reference because the getter for `bar` is accessed
return item.bar;
});
```

In case of usage with Angular 2+, it would integrate well with the `async` pipe:
```html

{{foo.bar | async}}


```

This feature can be useful when we do not want to resolve every reference to a resource if there are too many and/or if they are not used anywhere.

**NOTE**: It may not be possible to use the getter for a property on `Item`, this needs further investigation.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how Item references are resolved and how Item properties are accessed; the issue does not name files or tests. Investigate whether property getters can support lazy promise values, then define completion around async properties remaining unresolved until accessed while normal properties keep their existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.