Skip to content

Instantly share code, notes, and snippets.

@lmatteis
Created September 26, 2018 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmatteis/34aaf7c2c635d8eddf4f98304bf63a08 to your computer and use it in GitHub Desktop.
Save lmatteis/34aaf7c2c635d8eddf4f98304bf63a08 to your computer and use it in GitHub Desktop.
import React from 'react';
import Coroutine from 'react-coroutine';
import Deferred from './Deferred.js';
export default Coroutine.create(Counter);
async function* Counter() {
let counter = 0;
while (true) {
yield (
<section>
<p>{counter}</p>
<button onClick={() => dispatch('INCREMENT')}>Increment</button>
</section>
);
await waitFor('INCREMENT');
counter++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment