{"_id":"ink-broadcast","_rev":"7-d27fbaeaf04e37ff5ee6e5fab0dc3ccd","name":"ink-broadcast","dist-tags":{"latest":"0.3.0"},"versions":{"0.1.0":{"name":"ink-broadcast","version":"0.1.0","description":"Implementation of react-broadcast for ink","main":"dist/index.js","homepage":"https://github.com/jimmed/ink-broadcast","bugs":{"url":"https://github.com/jimmed/ink-broadcast/issues"},"repository":{"url":"https://github.com/jimmed/ink-broadcast","type":"git"},"author":{"name":"Jim O'Brien","email":"jim@jimmed.net"},"license":"MIT","scripts":{"build":"babel --out-dir dist src","watch":"yarn run build --watch","prepublishOnly":"yarn run build"},"dependencies":{"invariant":"^2.2.2","prop-types":"^15.6.0"},"peerDependencies":{"ink":"^0.4.1"},"devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-class-properties":"^6.24.1","babel-plugin-transform-export-extensions":"^6.22.0","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-react-jsx":"^6.24.1","babel-preset-env":"^1.6.1"},"_id":"ink-broadcast@0.1.0","dist":{"shasum":"fe05ca0d68cd90360216f41bb89f6ac7c550e46a","tarball":"https://registry.npmjs.org/ink-broadcast/-/ink-broadcast-0.1.0.tgz","fileCount":9,"unpackedSize":5555,"integrity":"sha512-fAJEDg2ePpqvG/gOVYTiC4zWWDDOhYvu+fy8lX09Axplyqrh3QpdOwczDzW8t5JagPwNVHZMgVzHMaE+uaHzRw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDN+F1RsQRYTl0WXNEn60WHEAGctOssjTu1CdyPwF2PWAIgQoqNV5kXiwB+a9V0UnwMSrhXdGxynpPNOokFPkLnPAU="}]},"maintainers":[{"name":"jimmed","email":"npm@jimmed.net"}],"_npmUser":{"name":"jimmed","email":"npm@jimmed.net"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ink-broadcast_0.1.0_1518277724033_0.2129636099274157"},"_hasShrinkwrap":false},"0.1.1":{"name":"ink-broadcast","version":"0.1.1","description":"Implementation of react-broadcast for ink","main":"dist/index.js","homepage":"https://github.com/jimmed/ink-broadcast","bugs":{"url":"https://github.com/jimmed/ink-broadcast/issues"},"repository":{"url":"https://github.com/jimmed/ink-broadcast","type":"git"},"author":{"name":"Jim O'Brien","email":"jim@jimmed.net"},"license":"MIT","scripts":{"build":"babel --out-dir dist src","watch":"yarn run build --watch","prepublishOnly":"yarn run build"},"dependencies":{"invariant":"^2.2.2","prop-types":"^15.6.0"},"peerDependencies":{"ink":"^0.4.1"},"devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-class-properties":"^6.24.1","babel-plugin-transform-export-extensions":"^6.22.0","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-react-jsx":"^6.24.1","babel-preset-env":"^1.6.1"},"engines":{"node":">=6"},"_id":"ink-broadcast@0.1.1","dist":{"shasum":"ae8bf889e08473f1d3f135cd0cdfccdb57b66179","tarball":"https://registry.npmjs.org/ink-broadcast/-/ink-broadcast-0.1.1.tgz","fileCount":9,"unpackedSize":5599,"integrity":"sha512-ee7vpLHGQu/6k9wlv3QxyzrRomjZgnTHshofeRwWi3mlYHFkaMGIFbQemO9HIJC5di/nJffPv4bPRCoFhDlnrQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH7PRhQUUWOg6PmGD5Rwk8breycJCbI88h9Kuuxy6TVsAiALRti0jpR1xBTipinyVqLKqKDQaWHSo2O+YwFigfZZ+g=="}]},"maintainers":[{"name":"jimmed","email":"npm@jimmed.net"}],"_npmUser":{"name":"jimmed","email":"npm@jimmed.net"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ink-broadcast_0.1.1_1518281821286_0.4497096525967177"},"_hasShrinkwrap":false},"0.1.2":{"name":"ink-broadcast","version":"0.1.2","description":"Implementation of react-broadcast for ink","main":"dist/index.js","homepage":"https://github.com/jimmed/ink-broadcast","bugs":{"url":"https://github.com/jimmed/ink-broadcast/issues"},"repository":{"url":"https://github.com/jimmed/ink-broadcast","type":"git"},"author":{"name":"Jim O'Brien","email":"jim@jimmed.net"},"license":"MIT","scripts":{"build":"babel --out-dir dist src","watch":"yarn run build --watch","prepublishOnly":"yarn run build"},"dependencies":{"invariant":"^2.2.2","prop-types":"^15.6.0"},"peerDependencies":{"ink":"^0.4.1"},"devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-class-properties":"^6.24.1","babel-plugin-transform-export-extensions":"^6.22.0","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-react-jsx":"^6.24.1","babel-preset-env":"^1.6.1"},"engines":{"node":">=6"},"_id":"ink-broadcast@0.1.2","dist":{"shasum":"b43839ed0d114aac57957a144fc6cb389c75793a","tarball":"https://registry.npmjs.org/ink-broadcast/-/ink-broadcast-0.1.2.tgz","fileCount":9,"unpackedSize":6877,"integrity":"sha512-jzJEFpJ1LdJaTw4pa5l3ZtEqEyMtAL0CUDo/Th8fdS0H1cfT+anOSxzEakaldaDoYO3X1Wy4QIw6HXLzwfVCzQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDFSB3MnnYekDJg8srpcymEAgJ9jlf8Vd/jO6vEGh9YSAiEAvns+eYQjf2F/mh/FmPgyHw7t2gXCO1il/865E7aVATI="}]},"maintainers":[{"name":"jimmed","email":"npm@jimmed.net"}],"_npmUser":{"name":"jimmed","email":"npm@jimmed.net"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ink-broadcast_0.1.2_1518282649756_0.5565707565550104"},"_hasShrinkwrap":false},"0.2.0":{"name":"ink-broadcast","version":"0.2.0","description":"Implementation of react-broadcast for ink","main":"dist/index.js","homepage":"https://github.com/jimmed/ink-broadcast","bugs":{"url":"https://github.com/jimmed/ink-broadcast/issues"},"repository":{"url":"https://github.com/jimmed/ink-broadcast","type":"git"},"author":{"name":"Jim O'Brien","email":"jim@jimmed.net"},"license":"MIT","scripts":{"build":"babel --out-dir dist src","watch":"yarn run build --watch","prepublishOnly":"yarn run build"},"dependencies":{"ink":"^0.4.1","invariant":"^2.2.2","prop-types":"^15.6.0"},"peerDependencies":{"ink":"^0.4.1"},"devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-class-properties":"^6.24.1","babel-plugin-transform-export-extensions":"^6.22.0","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-react-jsx":"^6.24.1","babel-preset-env":"^1.6.1"},"engines":{"node":">=6"},"_id":"ink-broadcast@0.2.0","dist":{"shasum":"8bc4cfc7c377a649835c0c3318ce78ad50eea47d","tarball":"https://registry.npmjs.org/ink-broadcast/-/ink-broadcast-0.2.0.tgz","fileCount":9,"unpackedSize":7165,"integrity":"sha512-FMQ6ht+bM3XQG97vo0O1vkRuy7s2hGMSsDswTWjKVA7Ma4q0tj5LEb2OLHzo/a13hI23ojNrjHV//idCQ0+t7A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHNFqWXERFC4usEHdvfhZNwF7oN/Jn07SuTHjbA3k+DnAiA/79yqgIlSRyGuGiHcLUYGz5BlocZCFDrsal32o6dl8w=="}]},"maintainers":[{"name":"jimmed","email":"npm@jimmed.net"}],"_npmUser":{"name":"jimmed","email":"npm@jimmed.net"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ink-broadcast_0.2.0_1518382883448_0.5805578194157164"},"_hasShrinkwrap":false},"0.3.0":{"name":"ink-broadcast","version":"0.3.0","description":"Implementation of react-broadcast for ink","main":"dist/index.js","homepage":"https://github.com/jimmed/ink-broadcast","bugs":{"url":"https://github.com/jimmed/ink-broadcast/issues"},"repository":{"url":"https://github.com/jimmed/ink-broadcast","type":"git"},"author":{"name":"Jim O'Brien","email":"jim@jimmed.net"},"license":"MIT","scripts":{"build":"babel --out-dir dist src","test":"jest src","prepublishOnly":"yarn run build"},"dependencies":{"ink":"^0.4.1","invariant":"^2.2.2","prop-types":"^15.6.0"},"peerDependencies":{"ink":"^0.4.1"},"devDependencies":{"babel-cli":"^6.26.0","babel-jest":"^22.4.1","babel-plugin-transform-class-properties":"^6.24.1","babel-plugin-transform-export-extensions":"^6.22.0","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-react-jsx":"^6.24.1","babel-preset-env":"^1.6.1","jest":"^22.4.2"},"engines":{"node":">=6"},"_id":"ink-broadcast@0.3.0","dist":{"shasum":"2f0a38168f5ec61c160407e0c195471cb59cb650","tarball":"https://registry.npmjs.org/ink-broadcast/-/ink-broadcast-0.3.0.tgz","fileCount":13,"unpackedSize":19179,"integrity":"sha512-TvmF9ujk3F08/ZugnXJXF/NDEz27NJPMSHYK69Oo3yl5MnN/H+e65aYrVA63Kfl7ajgZuNvVTWgTGcIM/R46hA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDZAkLGKbBuVC6AjFuCqXefnFO5rHquO9nJ2GUDvf3yUQIhAN3zE6shRdJQ8GY17lBH0vxKhmHMehTFQEzWQRzub6bD"}]},"maintainers":[{"name":"jimmed","email":"npm@jimmed.net"}],"_npmUser":{"name":"jimmed","email":"npm@jimmed.net"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ink-broadcast_0.3.0_1519504323349_0.598239644290756"},"_hasShrinkwrap":false}},"time":{"created":"2018-02-10T15:48:44.032Z","0.1.0":"2018-02-10T15:48:44.740Z","modified":"2022-06-19T01:20:42.514Z","0.1.1":"2018-02-10T16:57:01.974Z","0.1.2":"2018-02-10T17:10:50.482Z","0.2.0":"2018-02-11T21:01:24.086Z","0.3.0":"2018-02-24T20:32:03.400Z"},"maintainers":[{"name":"jimmed","email":"npm@jimmed.net"}],"description":"Implementation of react-broadcast for ink","homepage":"https://github.com/jimmed/ink-broadcast","repository":{"url":"https://github.com/jimmed/ink-broadcast","type":"git"},"author":{"name":"Jim O'Brien","email":"jim@jimmed.net"},"bugs":{"url":"https://github.com/jimmed/ink-broadcast/issues"},"license":"MIT","readme":"# ink-broadcast\n\nAn implementation of [react-broadcast][react-broadcast] for [ink][ink].\n\n# Installation\n\nUsing [yarn][yarn]:\n\n```\n$ yarn add ink-broadcast\n```\n\nThen, import using your preferred syntax:\n\n```js\n// using ES6 modules\nimport makeBroadcastContext from 'ink-broadcast'\n\n// using CommonJS modules\nvar makeBroadcastContext = require('ink-broadcast').default\n```\n\n# Usage\n\nThe default exported method will return you a pair of components: a `Broadcast` and a `Subscriber`. The two of these can be used together to pass data between components via\ncontext, while neatly sidestepping the issue of any other components blocking updates\nfurther down the tree, much like [react-broadcast][react-broadcast] does for React.\n\n```js\nconst { Broadcast, Subscriber } = makeBroadcastContext('someNewContextChannel')\n```\n\n## Example\n\nIn this example, we're going to build a context-powered theming engine for a fictional [ink][ink]\napplication. The use-case here is being able to write components that are theme-aware,\nwhile allowing control of the overall application theme from the top level.\n\nBelow, we create a top-level broadcaster, and reusable subscriber higher-order\ncomponent, and export them to use elsewhere in our application.\n\n```js\nimport { h, Component, Text } from 'ink'\nimport makeBroadcastContext from 'ink-broadcast'\n\nconst { Broadcast, Subscriber } = makeBroadcastContext('theme')\n\n/**\n * This component will wrap our application, allowing any subscribers\n * in the child component tree to subscribe to any changes to the theme.\n **/\nexport class ThemeProvider extends Component {\n  state = { colour: 'white' }\n\n  render() {\n    // This is the value we'll be broadcasting to any subscribers\n    const value = {\n      colour: this.state.colour,\n      setTheme: colour => this.setState({ colour })\n    }\n\n    return <Broadcast value={value}>{this.props.children}</Broadcast>\n  }\n}\n\n/**\n * This higher-order component will wrap any components that wish to subscribe\n * to the currently selected theme.\n **/\nexport const withTheme = WrappedComponent => props => (\n  <Subscriber>\n    {theme => <WrappedComponent {...props} theme={theme} />}\n  </Subscriber>\n)\n```\n\nNext, we wrap the top level of our application with our newly-created broadcaster:\n\n```js\nimport { h, render } from 'ink'\nimport { ThemeProvider } from './theme'\nimport App from './App'\n\nrender(\n  <ThemeProvider>\n    <App />\n  </ThemeProvider>\n)\n```\n\nFinally, let's make a theme-aware component:\n\n```js\nimport { h, Text } from 'ink'\nimport { withTheme } from './theme'\n\nconst SelectedThemeDetails = ({ theme }) => (\n  <div>\n    <Text white>\n      The currently selected theme is:\n    </Text>\n    {' '}\n    <Text bold keyword={theme.colour}>{theme.colour}</Text>\n  </div>\n)\n\nexport default withTheme(SelectedThemeDetails)\n```\n\nAssuming our `<App />` contains our new `SelectedThemeDetails` component, it\nwill render the currently selected theme.\n\n\n[react-broadcast]: https://github.com/ReactTraining/react-broadcast\n[ink]: https://github.com/vadimdemedes/ink\n[yarn]: https://yarnpkg.com\n","readmeFilename":"README.md"}