realar-project / realar

5 kB Advanced state manager for React

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

low: loop generators support

betula opened this issue · comments

[] Improve cycle to async operations and yield notation.

cycle(async ([isCancelled]) => {
  const data = await action;
  if (isCancelled()) return;
  // ...
});

cycle(function* (cancel) {
  const data = yield action;
  // ...
});

For supporting async cycle added a new function loop.

import { signal, stoppable, loop } from 'realar';

const action = signal();

loop(async () => {
  const stop = stoppable();

  const data = await action;
  if (stop.val) return;
  // ...
});

No have support generators yet, it's will soon.

Declined