{"id":20535426,"url":"https://github.com/xiscodev/store-and-pubsub","last_synced_at":"2026-04-21T04:32:58.288Z","repository":{"id":51261190,"uuid":"367974491","full_name":"xiscodev/store-and-pubsub","owner":"xiscodev","description":"A simple library to manage a Store and subscriptions to store values","archived":false,"fork":false,"pushed_at":"2021-05-18T17:07:56.000Z","size":347,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-06T03:28:33.296Z","etag":null,"topics":["browser","javascript-library","pubsub","store"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/store-and-pubsub","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xiscodev.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-16T20:03:28.000Z","updated_at":"2021-08-15T07:10:26.000Z","dependencies_parsed_at":"2022-09-07T12:10:29.598Z","dependency_job_id":null,"html_url":"https://github.com/xiscodev/store-and-pubsub","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/xiscodev/store-and-pubsub","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiscodev%2Fstore-and-pubsub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiscodev%2Fstore-and-pubsub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiscodev%2Fstore-and-pubsub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiscodev%2Fstore-and-pubsub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xiscodev","download_url":"https://codeload.github.com/xiscodev/store-and-pubsub/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiscodev%2Fstore-and-pubsub/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32076974,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T02:38:07.213Z","status":"ssl_error","status_checked_at":"2026-04-21T02:38:06.559Z","response_time":128,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","javascript-library","pubsub","store"],"created_at":"2024-11-16T00:31:15.111Z","updated_at":"2026-04-21T04:32:58.274Z","avatar_url":"https://github.com/xiscodev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv style=\"display: -ms-flexbox; display: -webkit-flex; display: flex; -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; -webkit-flex-wrap: wrap; -ms-flex-wrap: wrap; flex-wrap: wrap; -webkit-justify-content: center; -ms-flex-pack: center; justify-content: center; -webkit-align-content: center; -ms-flex-line-pack: center; align-content: center; -webkit-align-items: center; -ms-flex-align: center; align-items: center;\"\u003e\n  \u003cimg style=\"-webkit-order: 0; -ms-flex-order: 0; order: 0; -webkit-flex: 0 1 auto; -ms-flex: 0 1 auto; flex: 0 1 auto; -webkit-align-self: auto; -ms-flex-item-align: auto; align-self: auto;\" src=\"icon.png\" /\u003e\n\u003c/div\u003e\n\n\u003ch1 style=\"text-align:center;\"\u003eStore and PubSub\u003c/h1\u003e\n\n## What is this?\n\nA simple library to manage a Store and subscriptions to store values.\n\n## How to use it?\n\nFirst you need to import it in your project\n\n*The require way*\n\n```js\nlet { pullFrom, pushTo } = require(\"store-and-pubsub\");\n```\n\n*The import way*\n\n```js\nimport { unsetPath } from \"store-and-pubsub\";\n```\n\nThen use it to establish a store with getter and setter for a path, for example currentParam\n\n```js\nimport { pullFrom, pushTo } from \"store-and-pubsub\";\n\nconst MODULE_STORE_NAME = 'moduleStoreName'\n\n// INITIALIZE AN EMPTY STORE FOR YOUR MODULE\npushTo(MODULE_STORE_NAME, {})\n\n// CREATE A SETTER FOR SOME PATH TO STORE\npushTo(`${MODULE_STORE_NAME}.currentParam`, state)\n\n// CREATE A GETTER FOR SOME PATH TO RETRIEVE\npullFrom(`${MODULE_STORE_NAME}.currentParam`)\n```\n\nTo unset or push multiple values to store\n\n```js\nimport { unsetPath, pushValuesTo } from \"store-and-pubsub\";\n\nconst MODULE_STORE_NAME = 'moduleStoreName'\n\n// REMOVES THE PROPERTY AT PATH OF STORE\nunsetPath(`${MODULE_STORE_NAME}.currentParam`)\n\n// PUSHES MULTIPLE PROPERTIES AND VALUES AT PATH OF STORE\nconst values = {\n  prop1: \"value1\",\n  prop2: \"value2\",\n}\npushValuesTo(`${MODULE_STORE_NAME}`, values)\n```\n\nPaths from store can be subscribed for changes\n\n```js\nimport { subscribeToPath, unsubscribeFromPath, removeSubscription } from \"store-and-pubsub\";\n\nconst MODULE_STORE_NAME = 'moduleStoreName'\n\nconst path = `${MODULE_STORE_NAME}.currentParam`\n\nconst myCallback = () =\u003e {\n  // YOUR OWN CODE AND STUFF\n}\n\n// SUBSCRIBES TO moduleStoreName.currentParam CHANGES EXECUTING myCallback\nconst subscriber = subscribeToPath(path, myCallback)\n\n// REMOVES SUBSCRIPTION FRM GIVEN PATH\nunsubscribeFromPath(path)\n\n// GIVEN subscriber REMOVES IT FROM PATH SUBSCRIPTION\nremoveSubscription(subscription)\n\n// GIVEN myCallback REMOVES IT FROM ALL PATHS SUBSCRIBED\nremoveSubscription(myCallback)\n```\n\nPowered by [xiscodev](https://xisco.dev)\n\n\u003cdetails\u003e\n\u003csummary\u003eAdditional JSDOC info\u003c/summary\u003e\n\n### JSDOC\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n##### Table of Contents\n\n*   [pullFrom](#pullfrom)\n    *   [Parameters](#parameters)\n*   [pushTo](#pushto)\n    *   [Parameters](#parameters-1)\n*   [pushValuesTo](#pushvaluesto)\n    *   [Parameters](#parameters-2)\n*   [unsetPath](#unsetpath)\n    *   [Parameters](#parameters-3)\n*   [subscribeToPath](#subscribetopath)\n    *   [Parameters](#parameters-4)\n*   [unsubscribeFromPath](#unsubscribefrompath)\n    *   [Parameters](#parameters-5)\n*   [removeSubscription](#removesubscription)\n    *   [Parameters](#parameters-6)\n\n#### pullFrom\n\nRetrieves value from stored path.\n\nType: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)\n\n##### Parameters\n\n*   `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** locator string path to store\n\nReturns **any** can be anything stored at given path, anythng stored returns undefined\n\n#### pushTo\n\nPush value to path and notify if could publish.\n\nType: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)\n\n##### Parameters\n\n*   `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** locator string path to store\n*   `newValue` **any** the value to push\n*   `forceUpdate`   (optional, default `false`)\n\n#### pushValuesTo\n\nPush value to path.\n\nType: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)\n\n##### Parameters\n\n*   `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** locator string path to store\n*   `values` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** contains multiple keys and values to be pushed to store\n\n#### unsetPath\n\nRemoves path stored.\n\nType: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)\n\n##### Parameters\n\n*   `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** locator string path to store\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if unset has been effective, otherwise returns false\n\n#### subscribeToPath\n\nSubscribes to stored path changes with given callback.\n\nType: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)\n\n##### Parameters\n\n*   `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** locator string path to store\n*   `callback`  \n\nReturns **any** reference to be used to single unsubscribe\n\n#### unsubscribeFromPath\n\nUnsubscribe from given paths were has subscribed.\n\nType: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)\n\n##### Parameters\n\n*   `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** locator string path to store\n\n#### removeSubscription\n\nUnsubscribe from all paths were callback or subscriber has subscribed.\n\nType: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)\n\n##### Parameters\n\n*   `callbackOrSubscriber` **([Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function) | [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))** to unsubscribe\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiscodev%2Fstore-and-pubsub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiscodev%2Fstore-and-pubsub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiscodev%2Fstore-and-pubsub/lists"}