{"id":19460031,"url":"https://github.com/fongandrew/react-sub-dispatch","last_synced_at":"2025-02-25T12:22:12.158Z","repository":{"id":148042105,"uuid":"114583304","full_name":"fongandrew/react-sub-dispatch","owner":"fongandrew","description":"WIP","archived":false,"fork":false,"pushed_at":"2017-12-18T01:40:20.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-21T08:51:25.598Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fongandrew.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":"2017-12-18T01:39:54.000Z","updated_at":"2017-12-18T01:40:21.000Z","dependencies_parsed_at":"2023-04-10T21:31:32.337Z","dependency_job_id":null,"html_url":"https://github.com/fongandrew/react-sub-dispatch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fongandrew%2Freact-sub-dispatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fongandrew%2Freact-sub-dispatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fongandrew%2Freact-sub-dispatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fongandrew%2Freact-sub-dispatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fongandrew","download_url":"https://codeload.github.com/fongandrew/react-sub-dispatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240664498,"owners_count":19837563,"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-10T17:35:16.803Z","updated_at":"2025-02-25T12:22:12.125Z","avatar_url":"https://github.com/fongandrew.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-sub-dispatch\n[![Build Status](https://travis-ci.org/fongandrew/react-sub-dispatch.svg?branch=master)](https://travis-ci.org/fongandrew/react-sub-dispatch)\n\nA datastore-agnostic library for subscribing React components to a data source\nand dispatching events. Inspired by `react-redux`, but comes with a more\ngeneric interface for connecting stores.\n\n```ts\nconnect(\n  (context, ownProps) =\u003e ({\n    prop1: [Sub1, { store: context.store, key1: props.key1 }],\n    prop2: [Sub2, { store: context.store, key2: props.key2 }]\n  }),\n\n  (context, dispatch, ownProps) =\u003e ({\n\n  }),\n\n  (context, subProps, dispatchProps, ownProps) =\u003e ({\n\n  })\n);\n\nconnect(\n  (ownProps, context) =\u003e ({\n    prop1: [Sub1, { key1: props.key1 }, context],\n    prop2: [Sub2, { key2: props.key2 }, context]\n  }),\n\n  (dispatch, ownProps, context) =\u003e ({\n\n  }),\n\n  (subProps, dispatchProps, ownProps, context) =\u003e ({\n    ...subProps,\n    ...dispatchProps\n  })\n)\n\n```\n\nCould just use React context above.\nOr could use alt context set by provider ...\n\n```tsx\n\u003cProvider dispatcher={} getContext={}\u003e\n  \u003cMyApp /\u003e\n\u003c/Provider\u003e\n```\n\n```ts\nconnect((ownProps, services, dispatch) =\u003e ({\n  ...subscribe({\n    data1: subscribeToX(props),\n    data2: subscribeToY(props)\n  }),\n  onClick: () =\u003e dispatch({ type: 'INCR', value: 123 }),\n  otherProp: ownProps.value\n}));\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffongandrew%2Freact-sub-dispatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffongandrew%2Freact-sub-dispatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffongandrew%2Freact-sub-dispatch/lists"}