{"id":19011608,"url":"https://github.com/graphql-editor/state","last_synced_at":"2025-07-02T14:08:05.301Z","repository":{"id":100001698,"uuid":"144713708","full_name":"graphql-editor/state","owner":"graphql-editor","description":"State manager for typescript frontend \u0026 slothking","archived":false,"fork":false,"pushed_at":"2018-08-17T12:21:25.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-21T15:51:38.670Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/graphql-editor.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-14T11:55:38.000Z","updated_at":"2018-09-23T05:57:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb79b4c8-c981-4de9-a480-60f270807273","html_url":"https://github.com/graphql-editor/state","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/graphql-editor/state","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-editor%2Fstate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-editor%2Fstate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-editor%2Fstate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-editor%2Fstate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphql-editor","download_url":"https://codeload.github.com/graphql-editor/state/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-editor%2Fstate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263154344,"owners_count":23422009,"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-08T19:14:58.864Z","updated_at":"2025-07-02T14:08:05.269Z","avatar_url":"https://github.com/graphql-editor.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# State management for slothking frontend\n\nHello from [slothking.online](https://slothking.online)\nCommunicate with slothking backend without writing communication libs. Based on great lib [unstated](https://github.com/jamiebuilds/unstated)\n\n## Installation\n\n```sh\n$ npm install @slothking-online/state\n```\n\n## Usage\n\n```tsx\nimport { SlothContainer } from \"@slothking-online/state\";\nimport { Subscribe } from \"unstated\";\ntype MyState = {\n  someValue: string;\n  someOther: number[];\n};\n\nconst appName = \"superManager\";\nconst myContainer = new SlothContainer\u003cMyState\u003e(appName);\n\nfetch(\"myApiFunction/\").then(myContainer.set);\n\nconst MyReactComponent = () =\u003e (\n  \u003cSubscribe to={[myContainer]}\u003e\n    {(con: typeof myContainer) =\u003e \u003cdiv\u003e{con.state.someValue}\u003c/div\u003e}\n  \u003c/Subscribe\u003e\n);\n```\n\n## Usage with slothking generated api\n\n```tsx\nimport { SlothContainer } from \"@slothking-online/state\";\nimport { Subscribe } from \"unstated\";\nimport { userExtensionState } from './api';\n\nconst appName = \"superManager\";\nconst myContainer = new SlothContainer\u003cuserExtensionState\u003e(appName);\n\napi.user.endpoints.login(props:{username:'aaa',password:'ppp'}).then(myContainer.set)\n\nconst MyReactComponent = () =\u003e (\n  \u003cSubscribe to={[myContainer]}\u003e\n    {(con: typeof myContainer) =\u003e { return con.state.valid ? \u003cdiv\u003eUser logged in\u003c/div\u003e : \u003cdiv\u003eUser logged out\u003c/div\u003e}}\n  \u003c/Subscribe\u003e\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-editor%2Fstate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphql-editor%2Fstate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-editor%2Fstate/lists"}