{"action":"created","issue":{"url":"https://api.github.com/repos/alexanderjarvis/maybe/issues/13","repository_url":"https://api.github.com/repos/alexanderjarvis/maybe","labels_url":"https://api.github.com/repos/alexanderjarvis/maybe/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/alexanderjarvis/maybe/issues/13/comments","events_url":"https://api.github.com/repos/alexanderjarvis/maybe/issues/13/events","html_url":"https://github.com/alexanderjarvis/maybe/issues/13","id":242305175,"number":13,"title":"Only evaluating `.orJust()` return value when necessary","user":{"login":"Leeds-eBooks","id":4380655,"avatar_url":"https://avatars3.githubusercontent.com/u/4380655?v=4","gravatar_id":"","url":"https://api.github.com/users/Leeds-eBooks","html_url":"https://github.com/Leeds-eBooks","followers_url":"https://api.github.com/users/Leeds-eBooks/followers","following_url":"https://api.github.com/users/Leeds-eBooks/following{/other_user}","gists_url":"https://api.github.com/users/Leeds-eBooks/gists{/gist_id}","starred_url":"https://api.github.com/users/Leeds-eBooks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Leeds-eBooks/subscriptions","organizations_url":"https://api.github.com/users/Leeds-eBooks/orgs","repos_url":"https://api.github.com/users/Leeds-eBooks/repos","events_url":"https://api.github.com/users/Leeds-eBooks/events{/privacy}","received_events_url":"https://api.github.com/users/Leeds-eBooks/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-07-12T08:51:22Z","updated_at":"2018-02-08T08:58:50Z","closed_at":null,"author_association":"NONE","body":"Sorry, me again!\r\n\r\nI quite often find myself in something like the following situation:\r\n\r\n```js\r\nreturn maybe(props.boolean)\r\n  .filter(bool => bool)\r\n  .map(() =>\r\n    <ComponentIfTrue />\r\n  )\r\n  .orJust(\r\n    <ComponentIfFalse />\r\n  )\r\n```\r\n\r\nThe trouble is, as I understand it, `<ComponentIfFalse />` will always be evaluated, regardless of the value of `props.boolean`. Would there be the possibility of adding a new method called something like `.orJustCall()` to which you must pass a function, which is only called when the conditions lead to `orJust`? If so I'm happy to PR."},"comment":{"url":"https://api.github.com/repos/alexanderjarvis/maybe/issues/comments/364044951","html_url":"https://github.com/alexanderjarvis/maybe/issues/13#issuecomment-364044951","issue_url":"https://api.github.com/repos/alexanderjarvis/maybe/issues/13","id":364044951,"user":{"login":"alexanderjarvis","id":664238,"avatar_url":"https://avatars2.githubusercontent.com/u/664238?v=4","gravatar_id":"","url":"https://api.github.com/users/alexanderjarvis","html_url":"https://github.com/alexanderjarvis","followers_url":"https://api.github.com/users/alexanderjarvis/followers","following_url":"https://api.github.com/users/alexanderjarvis/following{/other_user}","gists_url":"https://api.github.com/users/alexanderjarvis/gists{/gist_id}","starred_url":"https://api.github.com/users/alexanderjarvis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexanderjarvis/subscriptions","organizations_url":"https://api.github.com/users/alexanderjarvis/orgs","repos_url":"https://api.github.com/users/alexanderjarvis/repos","events_url":"https://api.github.com/users/alexanderjarvis/events{/privacy}","received_events_url":"https://api.github.com/users/alexanderjarvis/received_events","type":"User","site_admin":false},"created_at":"2018-02-08T08:58:50Z","updated_at":"2018-02-08T08:58:50Z","author_association":"OWNER","body":"Hi @Leeds-eBooks, I actually faced a similar problem yesterday but solved it a different way. I started by looking at `branch` from `recompose` but ended up writing my own HOC instead.\r\n\r\n```\r\nimport * as React from 'react'\r\n\r\nexport function intercept<A: {}>(\r\n  condition: (props: A) => boolean,\r\n  Obstruction: React.ComponentType<A>,\r\n): (React.ComponentType<A>) => React.ComponentType<A> {\r\n  return Component => props => {\r\n    if (condition(props)) {\r\n      return <Obstruction {...props} />\r\n    } else {\r\n      return <Component {...props} />\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nThis lets you specify a component to display if the condition is true, and if not, it falls through the chain to the original component that it wraps. You can use it with `compose` and/or `connect` from redux."}}
{"actor":{"display_login":"alexanderjarvis"}}