{"id":22120173,"url":"https://github.com/joshbrew/statemanager","last_synced_at":"2025-03-24T06:26:37.297Z","repository":{"id":57180430,"uuid":"426372228","full_name":"joshbrew/StateManager","owner":"joshbrew","description":"Easy, optimized state management for UI and rapidly changing, large datasets","archived":false,"fork":false,"pushed_at":"2022-02-25T09:51:34.000Z","size":91,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T12:14:52.307Z","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":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joshbrew.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":"2021-11-09T20:13:28.000Z","updated_at":"2022-02-21T18:26:49.000Z","dependencies_parsed_at":"2022-09-14T03:31:16.781Z","dependency_job_id":null,"html_url":"https://github.com/joshbrew/StateManager","commit_stats":null,"previous_names":["brainsatplay/statemanager"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbrew%2FStateManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbrew%2FStateManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbrew%2FStateManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbrew%2FStateManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshbrew","download_url":"https://codeload.github.com/joshbrew/StateManager/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245220041,"owners_count":20579691,"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-12-01T14:21:19.616Z","updated_at":"2025-03-24T06:26:37.271Z","avatar_url":"https://github.com/joshbrew.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## StateManager.js\n\n![status](https://img.shields.io/npm/v/anotherstatemanager) \n![downloads](https://img.shields.io/npm/dt/anotherstatemanager)\n![size](https://img.shields.io/github/size/brainsatplay/StateManager/StateManager.js)\n![lic](https://img.shields.io/npm/l/anotherstatemanager)\n\n`npm i anotherstatemanager`\n\nSimple state manager.\n\nSet key responses to have functions fire when keyed values change. Can be set to run on a timer interval, or only fire when triggered, or you can stack sequential updates to fire per frame (e.g. summing key inputs). Very flexible, dependent on our ObjectListener.js\n\n\n\nExample:\n```\nimport {StateManager} from 'anotherstatemanager'\n\nlet state = new StateManager();\n\nlet sub = state.subscribe('x',(newx) =\u003e {console.log(newx);});\n\n\n\n\nstate.subscribe(key,onchange);\nstate.subscribeTrigger(key,onchange);\nstate.subsribeSequential(key,onchange);\n\nstate.unsubsribe(sub);\nstate.unsubscribeTrigger(sub);\nstate.unsubscribeSequential(sub);\n\nstate.subscribeOnce(key,onchange);\nstate.subscribeTriggerOnce(key,onchange);\nstate.subscribeSequentialOnce(key,onchange);\n//...\n\nstate.setState({x:3});\nstate.setState({...keys:values});\n\n```\n\nThere are 3 different state systems stacked on top of each other. You can set up the state\nmanager to only use triggers (by setting defaultKeyEventLoop to false on init) which run exclusively\non setState, avoiding needless timer checks. Individual subscriptions can be set to not run the checkers too, you can get pretty complicated but it's easier to keep different states with different schedules.\n\n\nThe rest of the functions are pretty much internal use only.\n\nYou can directly mutate state.data.x etc. which will still update the timer-check data, but will miss triggers.\n\nThe crux of this relies on a heavily modified JSON.stringifyFast function which lets you monitor large objects and arrays with a fast, shallow deep-copy system. We hammered it out to deal with giant objects or arrays etc. as lazily as possible, just watch your performance if you're also gonna be that lazy as it has a few catches.\n\n\n\nBy Joshua Brewster and Garrett Flynn\nLicense: AGPL v3.0\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshbrew%2Fstatemanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshbrew%2Fstatemanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshbrew%2Fstatemanager/lists"}