{"_id":"@atom-iq/context","_rev":"1-a2f45a96c947e80f7dac524ca40300db","name":"@atom-iq/context","dist-tags":{"latest":"0.2.0-alpha"},"versions":{"0.2.0-alpha":{"name":"@atom-iq/context","version":"0.2.0-alpha","description":"Atom-iQ Context Middleware","author":{"name":"Adam Filipek","email":"adamfilipek1@gmail.com","url":"https://github.com/adamf92"},"license":"MIT","main":"dist/index.umd.min.js","module":"dist/index.es.min.js","types":"dist/lib/types/src/index.d.ts","peerDependencies":{"@atom-iq/core":"0.2.0-alpha"},"devDependencies":{"@atom-iq/core":"^0.2.0-alpha"},"licenseText":"# MIT License\nCopyright (c) 2020 Adam Filipek\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","_id":"@atom-iq/context@0.2.0-alpha","dist":{"shasum":"62aa1dbca2f1ca8d7af8c13461d8a45837229885","integrity":"sha512-9Z1ml0l3dmR3elJaOM2MsPsOGdfgr2FqFv7ZuaithjTX0gWGH8bE+gt/ue30urgBF7/ndOP/5COSjxpnsptSww==","tarball":"https://registry.npmjs.org/@atom-iq/context/-/context-0.2.0-alpha.tgz","fileCount":54,"unpackedSize":22417,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfkE+nCRA9TVsSAnZWagAA+LgP/2XGpJqXpDsUixAdO2YZ\nx44cINB2JdVaLXodBKGY55uFzxNfqAGg2s49mK5iVzKFkUIMz5k4m7NFCP0d\nta8CvvovodGPwW+GzhpRhqZiawiE4qannozJdegKd0Q9PJ5G8iA4sf1OPGBX\n+tx8GEETSutwPABc/pxwm3SwNY6bbwYuZY+TKvi5dglG17ci3dfnR8Jvwnq0\nHjIoWx+vnGNJDDkjXrIprPRilfU2HYLxa/C78qTc6hsUT5lz7wEifsa8kjVw\nbOcsqLW4GZJrSga+9WhndFRVb4iwYTsU4LgwvZMBLPPgqkbtCkPGYQAL1tSr\naZ1MSYMJjOxisVje5uh86Z8Zn4HRb49oLP3bGLrtBH8xQ202txrysBYA1hr1\npdyJbedDM181OvppkAb9oPtUN5+TOtLHbiO8sKG2RlEWBKFNnDVxKThZmiP/\nyHb3NrsqhcXJxAJH5bWWw3wB/1mkp8B/Ktf06rhvG+akmkWcRDkOOHT4qNmS\nDDPI83WP0PgKCfsN3tgqF+7w+ouUwxK44VB95ptqsP2q+cX2n8oqMQY6M/UY\nbjib+eT8aoe5LeGYViLtU3ynH7Ep04SZ4559AKazNCL/ly7YaEmnaZnyY57K\nYzq8IRCNJ74yMMV3XwCDoP2smtu9aNQ5v2APYJSiCvG750iTxFoCekx57MED\nRzQr\r\n=FmbR\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD/A65g6ZRJ/zhQfGcZs1eFgiQ3st93Lh5vJ39RRzV3BQIgMnbqE6qCww68EUpYMvA9U5vO2Tnmjc7D9Naj0ojmRRs="}]},"maintainers":[{"name":"adamf","email":"adamfilipek1@gmail.com"}],"_npmUser":{"name":"adamf","email":"adamfilipek1@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/context_0.2.0-alpha_1603293095046_0.646186260559084"},"_hasShrinkwrap":false}},"time":{"created":"2020-10-21T15:11:34.736Z","0.2.0-alpha":"2020-10-21T15:11:35.177Z","modified":"2022-04-04T16:14:13.897Z"},"maintainers":[{"name":"adamf","email":"adamfilipek1@gmail.com"}],"description":"Atom-iQ Context Middleware","author":{"name":"Adam Filipek","email":"adamfilipek1@gmail.com","url":"https://github.com/adamf92"},"license":"MIT","readme":"# Atom-iQ Context Middleware (`@atom-iq/context`)\n#### Installing\n- npm - `npm install --save @atom-iq/context`\n- yarn - `yarn add @atom-iq/context`\n\n\n#### Context\nPackage containing Middlewares, provides access to Context API\n\nMiddlewares:\n- initContext - called on application init, provides initial root context object\n- createContext - Component Middleware, creates nested Context, that will be passed to children\n  and returns function, that's adding new fields to that Context\n- context (useContext) - Component Middleware, returns function that's getting Context field by name\n\nTools:\n- contextProvider function - factory for Context Provider Component - returns Component, that's using\n  createContext Middleware, providing new Context with specified field or fields to children\n\n#### Starting the app\n```typescript jsx\nimport App from './App'\nimport { createRvDOM, combineMiddlewares } from '@atom-iq/core'\nimport { contextMiddleware } from '@atom-iq/ref'\n\nconst initialRootContext = {\n  message: 'Atom-iQ Context Middleware'\n}\n\nconst middlewares = combineMiddlewares(contextMiddleware(initialRootContext))()\n\ncreateRvDOM(middlewares)(<App />, document.getElementById('root'))\n```\n\n#### Usage\n```typescript jsx\nimport { RvdComponent, createState } from '@atom-iq/core'\nimport { contextProvider, WithContext, WithCreateContext } from '@atom-iq/context'\n\nconst Consumer: RvdComponent<{}, WithContext> = (_props, { context }) => (\n  <section>\n    {context('message')}\n    {context('fromCreate')}\n  </section>\n)\n\nconst App: RvdComponent<{}, WithCreateContext & WithContext> = (_props, { createContext, context }) => {\n  createContext('fromCreate', 'Created in App by createContext')\n  \n  const Nested = contextProvider({\n    message: 'Nested message',\n    fromCreate: 'Nested fromCreate'\n  })\n  \n  return (\n    <main class=\"App\">\n      {context('message')} // 'Atom-iQ Context Middleware' - from root\n      {context('fromCreate')} // 'Created in App by createContext'\n      <Consumer /> // Same as above\n      <Nested>\n        <Consumer /> // 'Nested message' and 'Nested fromCreate'\n      </Nested>\n    </main>\n  )\n}\n\n```\n\n## Documentation\n- [Framework](../../README.md)\n- [Reactive Virtual DOM](../../docs/reactive-virtual-dom/REACTIVE-VIRTUAL-DOM.md)\n- [Component](../../docs/framework/COMPONENT.md)\n- [Elements](../../docs/framework/ELEMENTS.md)\n- [Middleware](../../docs/framework/MIDDLEWARE.md)\n\n","readmeFilename":"README.md"}