{"action":"created","issue":{"url":"https://api.github.com/repos/1stdibs/copy-text/issues/3","labels_url":"https://api.github.com/repos/1stdibs/copy-text/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/1stdibs/copy-text/issues/3/comments","events_url":"https://api.github.com/repos/1stdibs/copy-text/issues/3/events","html_url":"https://github.com/1stdibs/copy-text/pull/3","id":124140767,"number":3,"title":"Added a plugin for fluxible to add copy methods to context","user":{"login":"PeteJodo","id":1938892,"avatar_url":"https://avatars.githubusercontent.com/u/1938892?v=3","gravatar_id":"","url":"https://api.github.com/users/PeteJodo","html_url":"https://github.com/PeteJodo","followers_url":"https://api.github.com/users/PeteJodo/followers","following_url":"https://api.github.com/users/PeteJodo/following{/other_user}","gists_url":"https://api.github.com/users/PeteJodo/gists{/gist_id}","starred_url":"https://api.github.com/users/PeteJodo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PeteJodo/subscriptions","organizations_url":"https://api.github.com/users/PeteJodo/orgs","repos_url":"https://api.github.com/users/PeteJodo/repos","events_url":"https://api.github.com/users/PeteJodo/events{/privacy}","received_events_url":"https://api.github.com/users/PeteJodo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/1stdibs/copy-text/labels/don't%20merge","name":"don't merge","color":"eb6420"}],"state":"open","locked":false,"assignee":{"login":"antialias","id":447517,"avatar_url":"https://avatars.githubusercontent.com/u/447517?v=3","gravatar_id":"","url":"https://api.github.com/users/antialias","html_url":"https://github.com/antialias","followers_url":"https://api.github.com/users/antialias/followers","following_url":"https://api.github.com/users/antialias/following{/other_user}","gists_url":"https://api.github.com/users/antialias/gists{/gist_id}","starred_url":"https://api.github.com/users/antialias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antialias/subscriptions","organizations_url":"https://api.github.com/users/antialias/orgs","repos_url":"https://api.github.com/users/antialias/repos","events_url":"https://api.github.com/users/antialias/events{/privacy}","received_events_url":"https://api.github.com/users/antialias/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2015-12-28T23:28:13Z","updated_at":"2016-01-05T20:44:00Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/1stdibs/copy-text/pulls/3","html_url":"https://github.com/1stdibs/copy-text/pull/3","diff_url":"https://github.com/1stdibs/copy-text/pull/3.diff","patch_url":"https://github.com/1stdibs/copy-text/pull/3.patch"},"body":"### A Proposal for Copy Methods on Context\r\n\r\nA fluxible plugin that would add the additional methods: `getCopy` and `extendCopy` to the contexts: `ComponentContext`, `ActionContext`, and `StoreContext` (**note:** not on FluxibleContext).\r\n\r\nThis would allow easy access to copy for react component, actions, and stores without having to pass it down through props and payloads. It's also easy to start using, using the `message-center.js` entry file from adminv2 as an example, all that's needed is:\r\n```javascript\r\n// ...\r\nmessageCenterApp.plug(require('copy-text/plugins/fluxible/copyTextPlugin'));\r\nvar context = messageCenterApp.createContext({ svCopyPath: 'mc.copy' });\r\n// ...\r\n```\r\n\r\nSome catches downstream, when using `provideContext`, a second parameter should be passed that looks like...\r\n```javascript\r\nprovideContext(SomeTopLevelComponent, {\r\n    getCopy: React.PropTypes.function.isRequired,\r\n    extendCopy: React.PropTypes.function.isRequired\r\n});\r\n```\r\n\r\nMaybe I can add to the PR a helper that exports that object.\r\n\r\nAlso a user should add `contextTypes` to their component i.e.:\r\n```javascript\r\nSomeComponent.contextTypes = {\r\n    executeAction: React.PropTypes.function.isRequired,\r\n    getStore: React.PropTypes.function.isRequired,\r\n    getCopy: React.PropTypes.function.isRequired,\r\n    extendCopy: React.PropTypes.function.isRequired\r\n};\r\n```\r\n\r\nUsers only need to add the contextTypes that their component actually uses to reduce that boilerplate.\r\n\r\nAnd that's all that's required to use the plugin....\r\n```javascript\r\nrender() {\r\n    return <h1>{this.context.getCopy('myTitleKey')}</h1>;\r\n}\r\n```\r\n\r\n##### Additional notes\r\n- I didn't make this it's own module since it's related to copy-text and also copy-text requires `dibs-endpoints` which makes this have to be closed-source...no point using up another closed-source repo for our quota\r\n- not sure about `extendCopy` since each context instance gets it own copyText object, extending copy within a component would not be visible to actions **BUT** would be visible to child components (I'm pretty sure, since it's the same context getting passed down). Looking for feedback on that. Maybe not even include an `extendCopy` method?\r\n- this PR is incomplete, still need to do/write tests\r\n\r\n+@robrichard\r\n+@jrdrg \r\n+@twhid "},"comment":{"url":"https://api.github.com/repos/1stdibs/copy-text/issues/comments/169127362","html_url":"https://github.com/1stdibs/copy-text/pull/3#issuecomment-169127362","issue_url":"https://api.github.com/repos/1stdibs/copy-text/issues/3","id":169127362,"user":{"login":"PeteJodo","id":1938892,"avatar_url":"https://avatars.githubusercontent.com/u/1938892?v=3","gravatar_id":"","url":"https://api.github.com/users/PeteJodo","html_url":"https://github.com/PeteJodo","followers_url":"https://api.github.com/users/PeteJodo/followers","following_url":"https://api.github.com/users/PeteJodo/following{/other_user}","gists_url":"https://api.github.com/users/PeteJodo/gists{/gist_id}","starred_url":"https://api.github.com/users/PeteJodo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PeteJodo/subscriptions","organizations_url":"https://api.github.com/users/PeteJodo/orgs","repos_url":"https://api.github.com/users/PeteJodo/repos","events_url":"https://api.github.com/users/PeteJodo/events{/privacy}","received_events_url":"https://api.github.com/users/PeteJodo/received_events","type":"User","site_admin":false},"created_at":"2016-01-05T20:44:00Z","updated_at":"2016-01-05T20:44:00Z","body":"@robrichard I agree with that actually; going to remove it.\r\n@antialias That's what I suggested, I just don't want to create a new github repo so I was going to that right within this repo"}}