{"id":18358802,"url":"https://github.com/uppercod/zstate","last_synced_at":"2025-04-10T03:00:26.580Z","repository":{"id":57406710,"uuid":"307248676","full_name":"UpperCod/zstate","owner":"UpperCod","description":"Minimalist state manager, thought to sustain a state based on a mutable object that scales according to nodes.","archived":false,"fork":false,"pushed_at":"2020-10-28T00:40:18.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-15T20:05:53.863Z","etag":null,"topics":["state"],"latest_commit_sha":null,"homepage":"","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/UpperCod.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":"2020-10-26T03:09:17.000Z","updated_at":"2020-11-05T01:07:51.000Z","dependencies_parsed_at":"2022-09-05T06:00:10.458Z","dependency_job_id":null,"html_url":"https://github.com/UpperCod/zstate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"UpperCod/pkg-base","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fzstate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fzstate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fzstate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fzstate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UpperCod","download_url":"https://codeload.github.com/UpperCod/zstate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248148217,"owners_count":21055547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["state"],"created_at":"2024-11-05T22:19:33.928Z","updated_at":"2025-04-10T03:00:26.542Z","avatar_url":"https://github.com/UpperCod.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zstate\n\nMinimalist state manager, thought to sustain a state based on a mutable object that scales according to nodes.\n\n## Nodes?\n\nThe nodes are instances that are associated with the state, these instances allow isolated work, example:\n\n```js\nimport createState from \"zstate\";\n\nconst stateA = createState();\n\nconst stateB = A(\"b\");\n\nstateA.on(() =\u003e {\n    console.log(\"update\");\n});\n\nstateB.set({ name: \"Uppercod\" });\n```\n\nDel ejemplo podemos destacar :\n\n1. `stateA` contiene a `stateB`.\n2. `stateB` nunca conoce a `stateA`.\n\n## Install\n\n```\nnpm install zstore\n```\n\n## Usage\n\n```js\nimport state from \"zstate\";\n\nconst state = store({\n    toggle: false,\n});\n\nstate.on(() =\u003e {\n    console.log(\"update\");\n});\n\nconst toggle = ({ toggle }) =\u003e ({ toggle: !toggle });\n\nstate.set(toggle); // true\nstate.set(toggle); // false\n```\n\n## Instance\n\n```js\nimport createState from \"zstate\";\n\nconst app = createState(initialState);\n```\n\nCreates an instance of the state that returns a function that contains the following static properties and methods:\n\n### state\n\n```js\napp.state;\n```\n\nCurrent state.\n\n### set\n\n```js\napp.set({ any: \"value\" });\n```\n\nUpdate current state, `set` does not replace current state, just merge.\n\n**If the property to update is defined as null or undefined, example `{any: null}`, it will be removed from the object. if this property is a node, its effects on the parent will be eliminated**.\n\n### on\n\n```js\nconst off = app.on((state) =\u003e {\n    console.log(\"update:\", state);\n});\n```\n\nIt subscribes to state changes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuppercod%2Fzstate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuppercod%2Fzstate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuppercod%2Fzstate/lists"}