{"id":18013715,"url":"https://github.com/ide/autoproxy","last_synced_at":"2025-10-25T00:04:29.247Z","repository":{"id":36384045,"uuid":"40688921","full_name":"ide/autoproxy","owner":"ide","description":"A higher-order decorator to automatically proxy properties from the original function to the decorated one","archived":false,"fork":false,"pushed_at":"2015-08-17T20:26:47.000Z","size":136,"stargazers_count":13,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-14T17:21:56.125Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ide.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":"2015-08-14T01:08:30.000Z","updated_at":"2016-07-25T21:25:01.000Z","dependencies_parsed_at":"2022-08-28T13:00:29.922Z","dependency_job_id":null,"html_url":"https://github.com/ide/autoproxy","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/ide%2Fautoproxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ide%2Fautoproxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ide%2Fautoproxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ide%2Fautoproxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ide","download_url":"https://codeload.github.com/ide/autoproxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222155978,"owners_count":16940424,"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-10-30T03:22:48.173Z","updated_at":"2025-10-25T00:04:29.241Z","avatar_url":"https://github.com/ide.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# autoproxy\nA higher-order decorator to automatically proxy properties from the original function to the decorated one so that higher-order components don't get in the way.\n\n[![npm package](https://nodei.co/npm/autoproxy.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/autoproxy/)\n\n## How does autoproxy help?\n\nAutoproxy exposes a class' static and instance properties through a wrapper class.\n\nFor example, a React component with Redux looks like this:\n```js\n@connect(data =\u003e { size: data.layout.size })\nclass Box extends React.Component {\n  static NUMBER_OF_SIDES = 4;\n  bounce() {\n    ...\n  }\n  render() {\n    ...\n  }\n}\n```\n\nThis component defines a static property called `NUMBER_OF_SIDES` and method called `bounce`.\n\n### Without autoproxy\n\nWithout autoproxy, to access these properties we have to write code like this:\n```js\nclass Root extends React.Component {\n  render() {\n    return \u003cBox ref={component =\u003e { this._box = component; }} /\u003e;\n  }\n  componentDidMount() {\n    console.log('There are %d sides', Box.WrappedComponent.NUMBER_OF_SIDES);\n    this._box.getWrappedInstance().bounce();\n  }\n}\n```\n\nSee how we need `WrappedComponent` and `getWrappedInstance()`? This is because the `connect` decorator wraps the underlying class and `Box` refers to the wrapper class. As a result `Box.NUMBER_OF_SIDES` and `this._box.bounce` are both undefined.\n\n### With autoproxy\n\nWith `autoproxy`, the wrapper class automatically proxies the underlying class' properties. Use `@autoproxy` to decorate a decorator:\n\n```js\n@autoproxy(connect(data =\u003e { size: data.layout.size }))\nclass Box extends React.Component {\n  ...\n}\n```\n\nThen you can write `Box.NUMBER_OF_SIDES` and `this._box.bounce`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fide%2Fautoproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fide%2Fautoproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fide%2Fautoproxy/lists"}