{"id":18358814,"url":"https://github.com/uppercod/statenano","last_synced_at":"2025-04-06T13:31:38.261Z","repository":{"id":57370009,"uuid":"110629600","full_name":"UpperCod/statenano","owner":"UpperCod","description":"💡 StateNano is a small state handler with a fairly simple API, which exploits the potential of classes when managing states in an application.","archived":false,"fork":false,"pushed_at":"2018-04-16T21:02:58.000Z","size":65,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-18T14:11:29.735Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","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":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-14T02:26:58.000Z","updated_at":"2020-11-06T08:00:39.000Z","dependencies_parsed_at":"2022-08-29T11:01:58.114Z","dependency_job_id":null,"html_url":"https://github.com/UpperCod/statenano","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fstatenano","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fstatenano/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fstatenano/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fstatenano/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UpperCod","download_url":"https://codeload.github.com/UpperCod/statenano/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247488536,"owners_count":20946957,"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":[],"created_at":"2024-11-05T22:19:35.716Z","updated_at":"2025-04-06T13:31:37.777Z","avatar_url":"https://github.com/UpperCod.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Statenano\n\nStatenano is a small state handler with a fairly simple API, which exploits the potential of classes when managing states in an application.\n\n## Why use classes?\n\nthe classes offer a simple and minimalist inheritance, **Statenano** uses this to compose states based on classes.\n\n### yarn\n\n```bash\nyarn add -D statenano\n```\n### npm\n\n```bash\nnpm install -D statenano\n```\n\n## Instancia\n\nStatenano by default has a simple interface with 2 methods **update** and **subscribe**, **update** feeds the state with new properties and in turn notifies subscribers of each update.\n\n```javascript\n\nimport State from \"statenano\";\n\nlet initState = { type: \"sample\" };\n\n\nlet state = new State(initState);\n\n```\n#### initialState\n\nas you noticed in the previous instance you can define an initial state as the first argument of **State**\n\n### instance.update([mixed objet])\n\nallows subscribers to alert a change within the state\n\n```javascript\n\nimport State from \"statenano\";\n\nlet state = new State();\n\nstate.subscribe(state =\u003e {});\n\nstate.update({ type: \"sample\" });\n\n```\n\n### instance.subscribe( function ) \n\nallows you to subscribe to a status update\n\n## Inheritance \n\nStatenano to be a class facilitates the edition of behavior based on the inheritance\n\n```javascript\nimport State from \"statenano\";\n\nclass Todo extends State{\n    constructor(){\n        super();\n        this.tasks = [];\n    }\n    addTask(task){\n        this.update({\n            tasks : this.tasks.concat({task})\n        })\n    }\n    removeTask(task){\n        this.update({\n            tasks : this.tasks.filter((save)=\u003esave !== task)\n        })\n    }\n}\n\n\nlet state = new Todo;\n\n    state.subscribe(()=\u003e{\n        state.tasks.map((task)=\u003e{\n            console.log(task)\n        })\n    })\n\n    state.addTask(\"Learn statenano\");\n    \n```\n\n### Examples\n\n| Tipo | link |\n|------|-----|\n|TODO|[CodeSandbox](https://codesandbox.io/s/2435rkwjzj)|\n|SHOP|[Productos - Bodeguita Agroecologica](http://www.bodeguitaagroecologica.cl/producto/)|\n\n\n| npm | git | uso |\n|-----|-----|-----|\n| [preact-statenano](https://www.npmjs.com/package/preact-statenano) | [preact-statenano](https://github.com/UpperCod/preact-statenano) | Is a small library that allows you to synchronize state events created on the basis of Statenano with components created with preact all thanks to the high order components. |\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuppercod%2Fstatenano","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuppercod%2Fstatenano","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuppercod%2Fstatenano/lists"}