{"id":16506171,"url":"https://github.com/keller-mark/use-coordination","last_synced_at":"2025-03-16T18:32:32.814Z","repository":{"id":222719488,"uuid":"712458213","full_name":"keller-mark/use-coordination","owner":"keller-mark","description":"Implement coordinated multiple views in React-based visualization systems.","archived":false,"fork":false,"pushed_at":"2025-01-28T15:51:19.000Z","size":1922,"stargazers_count":7,"open_issues_count":17,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T18:08:26.946Z","etag":null,"topics":["hidivelab"],"latest_commit_sha":null,"homepage":"https://use-coordination.dev/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keller-mark.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2023-10-31T14:07:33.000Z","updated_at":"2025-01-28T15:51:23.000Z","dependencies_parsed_at":"2024-07-23T23:27:25.841Z","dependency_job_id":"edc0255a-3fc5-4e94-8fdb-fdf867f0c302","html_url":"https://github.com/keller-mark/use-coordination","commit_stats":null,"previous_names":["keller-mark/use-coordination"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keller-mark%2Fuse-coordination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keller-mark%2Fuse-coordination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keller-mark%2Fuse-coordination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keller-mark%2Fuse-coordination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keller-mark","download_url":"https://codeload.github.com/keller-mark/use-coordination/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826780,"owners_count":20354220,"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":["hidivelab"],"created_at":"2024-10-11T15:17:39.983Z","updated_at":"2025-03-16T18:32:32.788Z","avatar_url":"https://github.com/keller-mark.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use-coordination\n\nA library for coordinated multiple views in React-based visualization systems.\n\n\n## Usage\n\n```sh\nnpm install use-coordination\n```\n\n### Quick start\n\n- Define a coordination specification (i.e., representation of the coordinated state of your app) using the [declarative](https://keller-mark.github.io/use-coordination/docs/spec-json/) or [imperative](https://keller-mark.github.io/use-coordination/docs/spec-js/) API.\n- Get and set coordinated state via the `useCoordination` [hooks](https://keller-mark.github.io/use-coordination/docs/view-hooks/) within React components (i.e., views).\n- Wrap the views with a [coordination provider](https://keller-mark.github.io/use-coordination/docs/provider-components/).\n\n\n### Basics\n\nIn React components that define views, use the [hooks](https://keller-mark.github.io/use-coordination/docs/view-hooks/#usecoordination) from `use-coordination` to get and set values in the coordination space.\nFor example, if we want our view to be coordinated on a coordination type called `myValue`:\n\n```js\nimport React from 'react';\nimport { useCoordination } from 'use-coordination';\n\nfunction SomeViewType(props) {\n  const { viewUid } = props;\n  const [{\n    myValue,\n  }, {\n    setMyValue,\n  }] = useCoordination(viewUid, ['myValue']);\n\n  return (\n    \u003cinput\n      type=\"number\"\n      value={myValue}\n      onChange={e =\u003e setMyValue(e.target.value)}\n    /\u003e\n  );\n}\n```\n\nThen, wrap the app (or a parent component of all views you would like to coordinate) in a [CoordinationProvider](https://keller-mark.github.io/use-coordination/docs/provider-components/#coordinationprovider) (or [ZodCoordinationProvider](https://keller-mark.github.io/use-coordination/docs/provider-components/#zodcoordinationprovider)).\nPass a `spec` to the provider to set the initial state of the coordination space and the view-coordination scope mappings.\n\n\n```js\nimport React from 'react';\nimport { CoordinationProvider, defineSpec } from 'use-coordination';\n\n// ...\n\n// Alternatively, use the object-oriented API.\nconst initialSpec = defineSpec({\n  coordinationSpace: {\n    myValue: {\n      myValueScope1: 99,\n      myValueScope2: 20,\n    },\n  },\n  viewCoordination: {\n    v1: {\n      coordinationScopes: {\n        myValue: 'myValueScope1',\n      },\n    },\n    v2: {\n      coordinationScopes: {\n        myValue: 'myValueScope1',\n      },\n    },\n    v3: {\n      coordinationScopes: {\n        myValue: 'myValueScope2',\n      },\n    },\n  },\n});\n\nfunction MyApp(props) {\n  return (\n    \u003cCoordinationProvider spec={initialSpec}\u003e\n      \u003cSomeViewType viewUid=\"v1\" /\u003e\n      \u003cSomeViewType viewUid=\"v2\" /\u003e\n      \u003cAnotherViewType viewUid=\"v3\" /\u003e\n    \u003c/CoordinationProvider\u003e\n  );\n}\n```\n\nTo learn more, please visit the [documentation](https://keller-mark.github.io/use-coordination/):\n- [List of available hooks](https://keller-mark.github.io/use-coordination/docs/view-hooks/)\n- [List of available providers](https://keller-mark.github.io/use-coordination/docs/provider-components/)\n- [JSON schema](https://keller-mark.github.io/use-coordination/docs/spec-json/)\n- [Object-oriented spec API](https://keller-mark.github.io/use-coordination/docs/spec-js/)\n\n\n## Development\n\nInstall pnpm v8\n\n### Setup\n\n```sh\ngit clone \npnpm install\n```\n\n### Run demo\n\n```sh\npnpm start\n```\n\n### Lint and format\n\n```sh\npnpm lint\npnpm format\n```\n\n### Build library\n\n```sh\npnpm build\n```\n\n### Build demo\n\n```sh\npnpm build-demo\n```\n\n### Monorepo tasks\n\n```sh\npnpm meta-updater\n```\n\n\n## Citation\n\nTo cite Use-Coordination in your work, please use:\n\n```bibtex\n@inproceedings{keller2024usecoordination,\n  author={Keller, Mark S. and Manz, Trevor and Gehlenborg, Nils},\n  booktitle={2024 IEEE Visualization and Visual Analytics (VIS)}, \n  title={Use-Coordination: Model, Grammar, and Library for Implementation of Coordinated Multiple Views}, \n  year={2024},\n  volume={},\n  number={},\n  pages={166-170},\n  doi={10.1109/VIS55277.2024.00041}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeller-mark%2Fuse-coordination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeller-mark%2Fuse-coordination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeller-mark%2Fuse-coordination/lists"}