{"action":"created","issue":{"url":"https://api.github.com/repos/kadirahq/mantra/issues/147","repository_url":"https://api.github.com/repos/kadirahq/mantra","labels_url":"https://api.github.com/repos/kadirahq/mantra/issues/147/labels{/name}","comments_url":"https://api.github.com/repos/kadirahq/mantra/issues/147/comments","events_url":"https://api.github.com/repos/kadirahq/mantra/issues/147/events","html_url":"https://github.com/kadirahq/mantra/issues/147","id":141419850,"number":147,"title":"Client side filtering of collection","user":{"login":"sungwoncho","id":8265228,"avatar_url":"https://avatars.githubusercontent.com/u/8265228?v=3","gravatar_id":"","url":"https://api.github.com/users/sungwoncho","html_url":"https://github.com/sungwoncho","followers_url":"https://api.github.com/users/sungwoncho/followers","following_url":"https://api.github.com/users/sungwoncho/following{/other_user}","gists_url":"https://api.github.com/users/sungwoncho/gists{/gist_id}","starred_url":"https://api.github.com/users/sungwoncho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sungwoncho/subscriptions","organizations_url":"https://api.github.com/users/sungwoncho/orgs","repos_url":"https://api.github.com/users/sungwoncho/repos","events_url":"https://api.github.com/users/sungwoncho/events{/privacy}","received_events_url":"https://api.github.com/users/sungwoncho/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-03-16T22:20:44Z","updated_at":"2016-11-24T07:57:48Z","closed_at":null,"body":"I would like to know if there is any problem with the way I am implementing the client side search.\n\nI have a component in which users can use search input to filter the documents to be displayed. The component receives an array of documents from a container.\n\n_container_\n\n``` js\nexport const composer = ({context}, onData) => {\n  const {Meteor, Collections} = context();\n\n  if (Meteor.subscribe('foos').ready()) {\n    let foos = Collections.Foos.find({some: condition}).fetch();\n\n    onData(null, {foos});\n  }\n};\n```\n\nTo implement the search, I made my component stateful:\n\n``` js\nclass MyComponent extends React.Component {\n  ...\n  render() {\n    <ul>\n          {\n            foos.filter(foo => {\n              let searchRegex = new RegExp(_.escapeRegExp(this.state.searchTerm), 'i');\n              return searchRegex.test(foo.name);\n            }).map(foo => {\n              return <li>{foo.name}</li>;\n            })\n          }\n      </ul>\n  }\n}\n```\n\nIs filtering the documents a job of the container? I could delegate the job to the container by LocalState but I feel uneasy because LocalState is shared across the whole app, but in this case I don't need my state app-wide.\n"},"comment":{"url":"https://api.github.com/repos/kadirahq/mantra/issues/comments/262712358","html_url":"https://github.com/kadirahq/mantra/issues/147#issuecomment-262712358","issue_url":"https://api.github.com/repos/kadirahq/mantra/issues/147","id":262712358,"user":{"login":"achtan","id":1048212,"avatar_url":"https://avatars.githubusercontent.com/u/1048212?v=3","gravatar_id":"","url":"https://api.github.com/users/achtan","html_url":"https://github.com/achtan","followers_url":"https://api.github.com/users/achtan/followers","following_url":"https://api.github.com/users/achtan/following{/other_user}","gists_url":"https://api.github.com/users/achtan/gists{/gist_id}","starred_url":"https://api.github.com/users/achtan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/achtan/subscriptions","organizations_url":"https://api.github.com/users/achtan/orgs","repos_url":"https://api.github.com/users/achtan/repos","events_url":"https://api.github.com/users/achtan/events{/privacy}","received_events_url":"https://api.github.com/users/achtan/received_events","type":"User","site_admin":false},"created_at":"2016-11-24T07:57:48Z","updated_at":"2016-11-24T07:57:48Z","body":"use `onSearch` in your component as an event handler for search action.\r\n\r\n````\r\n<input onChange={onSearch}/>\r\n````"}}
{"actor":{"display_login":"achtan"}}