{"action":"opened","issue":{"url":"https://api.github.com/repos/reactjs/react-future/issues/45","repository_url":"https://api.github.com/repos/reactjs/react-future","labels_url":"https://api.github.com/repos/reactjs/react-future/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/reactjs/react-future/issues/45/comments","events_url":"https://api.github.com/repos/reactjs/react-future/issues/45/events","html_url":"https://github.com/reactjs/react-future/issues/45","id":135882623,"number":45,"title":"Generators for async sequences","user":{"login":"natew","id":12100,"avatar_url":"https://avatars.githubusercontent.com/u/12100?v=3","gravatar_id":"","url":"https://api.github.com/users/natew","html_url":"https://github.com/natew","followers_url":"https://api.github.com/users/natew/followers","following_url":"https://api.github.com/users/natew/following{/other_user}","gists_url":"https://api.github.com/users/natew/gists{/gist_id}","starred_url":"https://api.github.com/users/natew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natew/subscriptions","organizations_url":"https://api.github.com/users/natew/orgs","repos_url":"https://api.github.com/users/natew/repos","events_url":"https://api.github.com/users/natew/events{/privacy}","received_events_url":"https://api.github.com/users/natew/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-23T22:10:27Z","updated_at":"2016-02-23T22:10:27Z","closed_at":null,"body":"Looking at the latest update in 05 - Async, I really like the syntax coming together here. It seems to give you most of what you need to write components as functions, with the additional benefit of async ordered actions, and what looks to be some sort of first-class redux style internal dispatch system.\r\n\r\nI'd like to implement this. I've actually come up with a syntax very similar that we've been testing (emailed you a while back), and it's actually not too far off of this.\r\n\r\nOne big question comes up. This seems to either imply that you are re-instantiating the move function every time the view renders, or you are simply not showing a way to have a render() function equivalent. That being one of the big upsides of React, I'm curious the intent.\r\n\r\nI could imagine extending it to be something like this:\r\n\r\n```js\r\n\r\nlet Foo : Component<PropTypes> = ({ state = initState, props, update, dispatch }) => {\r\n  function* move({ x, y }, cancelMove) {\r\n    yield state.cancelMove()\r\n    yield update({ ...state, cancelMove, x, y, })\r\n    yield sleep(500)\r\n    yield dispatch({ action: 'STOPPED_MOVING' })\r\n    yield update({ ...state, stops: stops + 1 })\r\n    yield props.onStop({\r\n      lastPosition: [state.x, state.y]\r\n    }, cancel)\r\n  }\r\n\r\n  return (props, state) => {\r\n\r\n    // do stuff..\r\n\r\n    return (\r\n      <div\r\n        onMouseMove={move}\r\n        onMouseLeave={e => state.cancelMove()}>\r\n        Stopped moving {state.stops} times.\r\n      </div>\r\n    )\r\n  }\r\n}\r\n```\r\n\r\nWhere the returned function now lets you react to things. Though this adds a bit of verbosity and repitition. I could be way off though here, is it really not a big deal to re-instantiate functions within the render? Or was this just a simple sketch and hasn't accounted for the render function case."}}