Skip to content

draft: experimenting with primitives/types to support reactive GeneratorState #10258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

runspired
Copy link
Contributor

@runspired runspired commented Aug 18, 2025

very borked, mostly a skratchpad for toying around with the types. Best I can tell there's no path to typing generator functions adequately, we'll want to compile similar to ember-concurrency.

I would update the compiler semantics though to make it more of a direct sugar overtop of generator functions. Something like this, though perhaps we can setup generator-transforms to understand a few functions whose arguments should be considered to be generators.

import { task } from '@warp-drive/experiments/task';
import { _f, _yield, _yieldX } from 'generator-transforms';

const task = createTask(_f(async function doThing() {
  // not yielded
  const result = await otherThing();
  // yield
  const state = await _yield(doStillMore());
  // yield*
  const moreState = await _yieldX(stuff());
}));
const task = createTask(function* doThing() {
  const state1 = yield doStillMore();
  const state2 = yield* stuff();
});

const task2 = createTask(async function* doAsyncThing() {
  const result = await otherThing();
  const state1 = yield doStillMore(result);
  const state2 = yield* stuff();
});
@localResource('my-key')
class MyComponent extends Component {
  @property isExpanded = false;
  
  @signal myTask = null;
  
  update = () => { this.myTask = myTask(); }
  
  <template></template>
}

Related: microsoft/TypeScript#42033

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: needs triage
Development

Successfully merging this pull request may close these issues.

1 participant