{"action":"closed","issue":{"url":"https://api.github.com/repos/CharlesMangwa/react-data-fetching/issues/20","repository_url":"https://api.github.com/repos/CharlesMangwa/react-data-fetching","labels_url":"https://api.github.com/repos/CharlesMangwa/react-data-fetching/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/CharlesMangwa/react-data-fetching/issues/20/comments","events_url":"https://api.github.com/repos/CharlesMangwa/react-data-fetching/issues/20/events","html_url":"https://github.com/CharlesMangwa/react-data-fetching/issues/20","id":337151066,"node_id":"MDU6SXNzdWUzMzcxNTEwNjY=","number":20,"title":"Enable to pass in a side-effect","user":{"login":"busypeoples","id":718727,"node_id":"MDQ6VXNlcjcxODcyNw==","avatar_url":"https://avatars1.githubusercontent.com/u/718727?v=4","gravatar_id":"","url":"https://api.github.com/users/busypeoples","html_url":"https://github.com/busypeoples","followers_url":"https://api.github.com/users/busypeoples/followers","following_url":"https://api.github.com/users/busypeoples/following{/other_user}","gists_url":"https://api.github.com/users/busypeoples/gists{/gist_id}","starred_url":"https://api.github.com/users/busypeoples/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/busypeoples/subscriptions","organizations_url":"https://api.github.com/users/busypeoples/orgs","repos_url":"https://api.github.com/users/busypeoples/repos","events_url":"https://api.github.com/users/busypeoples/events{/privacy}","received_events_url":"https://api.github.com/users/busypeoples/received_events","type":"User","site_admin":false},"labels":[{"id":1027732678,"node_id":"MDU6TGFiZWwxMDI3NzMyNjc4","url":"https://api.github.com/repos/CharlesMangwa/react-data-fetching/labels/discussion%20%F0%9F%92%AC","name":"discussion 💬","color":"8e3a3a","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-29T22:06:48Z","updated_at":"2018-08-18T00:42:56Z","closed_at":"2018-08-18T00:42:56Z","author_association":"NONE","body":"**Opening an issue for documentation purposes.** A PR covering this issue will follow.\r\nSorry @CharlesMangwa for delaying this for some time now.\r\nEnable to pass in a callback that `react-data-fetch` either runs on `componentDidMount` or via passing down a `run` function f.e., enabling to define when the fetch is run in user land.\r\nThis should solve the following issues:\r\n* Being able to run multiple fetches serially or in parallel\r\n* Enable to delay or re-run a fetch when needed\r\n* Best case is implementing this in a fashion where we can run `Tasks` or `Promises`, leaving the \r\nactual implementation to user land.\r\n\r\nThe following is not the actual implementation, but an initial idea.\r\n\r\n```\r\nconst dataFetch = () => {\r\n     return fetch(SOME_URL_ENDPOINT)\r\n      .then(response => response.json());\r\n}\r\n\r\nexport default class App extends Component {\r\n  render() {\r\n    return (\r\n      <Fetch\r\n        loader={<Loader/>} // Replace this with your lovely handcrafted loader\r\n        run={dataFetch}\r\n      >\r\n        {({ data, run /* can also be passed down and used inside a class component f.e. */ }) => (\r\n         <div>\r\n          <h1>Username</h1>\r\n          <p>{data.name}</p>\r\n         </div>\r\n        )}\r\n      </Fetch>\r\n    )\r\n  }\r\n}\r\n\r\n```"}}
{"actor":{"display_login":"CharlesMangwa"}}