{"id":18487282,"url":"https://github.com/meinto/react-native-event-listeners","last_synced_at":"2025-05-08T21:06:55.824Z","repository":{"id":20387748,"uuid":"89812571","full_name":"meinto/react-native-event-listeners","owner":"meinto","description":"global event listener extension for react or react-native","archived":false,"fork":false,"pushed_at":"2023-01-04T21:45:29.000Z","size":962,"stargazers_count":207,"open_issues_count":20,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-29T19:02:54.013Z","etag":null,"topics":["event-listener","react","react-native"],"latest_commit_sha":null,"homepage":"","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/meinto.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":"2017-04-29T20:58:55.000Z","updated_at":"2024-10-10T15:12:22.000Z","dependencies_parsed_at":"2023-01-13T20:56:53.008Z","dependency_job_id":null,"html_url":"https://github.com/meinto/react-native-event-listeners","commit_stats":null,"previous_names":["tobiasmeinhardt/react-native-event-listeners"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meinto%2Freact-native-event-listeners","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meinto%2Freact-native-event-listeners/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meinto%2Freact-native-event-listeners/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meinto%2Freact-native-event-listeners/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meinto","download_url":"https://codeload.github.com/meinto/react-native-event-listeners/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238044093,"owners_count":19407128,"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":["event-listener","react","react-native"],"created_at":"2024-11-06T12:50:22.453Z","updated_at":"2025-02-10T02:04:22.903Z","avatar_url":"https://github.com/meinto.png","language":"JavaScript","funding_links":["https://opencollective.com/react-native-event-listeners","https://opencollective.com/react-native-event-listeners/contribute","https://opencollective.com/react-native-event-listeners/organization/0/website","https://opencollective.com/react-native-event-listeners/organization/1/website","https://opencollective.com/react-native-event-listeners/organization/2/website","https://opencollective.com/react-native-event-listeners/organization/3/website","https://opencollective.com/react-native-event-listeners/organization/4/website","https://opencollective.com/react-native-event-listeners/organization/5/website","https://opencollective.com/react-native-event-listeners/organization/6/website","https://opencollective.com/react-native-event-listeners/organization/7/website","https://opencollective.com/react-native-event-listeners/organization/8/website","https://opencollective.com/react-native-event-listeners/organization/9/website"],"categories":["JavaScript"],"sub_categories":[],"readme":"# React Native Event Listeners\n\n(This package isn't only restricted to react-native projects. The source is written in plain js with no dependencies to react-native.)\n\n[![Financial Contributors on Open Collective](https://opencollective.com/react-native-event-listeners/all/badge.svg?label=financial+contributors)](https://opencollective.com/react-native-event-listeners) [![npm version](https://badge.fury.io/js/react-native-event-listeners.svg)](https://badge.fury.io/js/react-native-event-listeners)\n[![dependencie status](https://david-dm.org/tobiasMeinhardt/react-native-event-listeners.svg)](https://david-dm.org/tobiasMeinhardt/react-native-event-listeners)\n[![dev-dependency status](https://david-dm.org/tobiasMeinhardt/react-native-event-listeners/dev-status.svg)](https://david-dm.org/tobiasMeinhardt/react-native-event-listeners?type=dev)\n[![npm](https://img.shields.io/npm/dm/react-native-event-listeners.svg)](https://www.npmjs.com/package/react-native-event-listeners)\n[![npm](https://img.shields.io/npm/dt/react-native-event-listeners.svg)](https://www.npmjs.com/package/react-native-event-listeners)\n[![travis build](https://travis-ci.org/meinto/react-native-event-listeners.svg?branch=master)](https://travis-ci.org/meinto/react-native-event-listeners)\n[![Coverage Status](https://coveralls.io/repos/github/meinto/react-native-event-listeners/badge.svg?branch=master)](https://coveralls.io/github/meinto/react-native-event-listeners?branch=master)\n\n## Why\n\nIn some very specific cases it can be charming to have a simple global event listener. While working with global event listeners **you don't have to pass touch events through the component tree** into other components or can **bypass easily the redux architecture** for example.\n\n## Installation\n\n```\nnpm install --save react-native-event-listeners\n```\n\nor\n\n```\nyarn add react-native-event-listeners\n```\n\n## Usage Example\n\n*Hint: The event listeners also work across different files. You only have to import the ```EventRegister``` in every file you need to send or receive your events.*\n\n```javascript\nimport { EventRegister } from 'react-native-event-listeners'\n\n/*\n * RECEIVER COMPONENT\n */\nclass Receiver extends PureComponent {\n    constructor(props) {\n        super(props)\n        \n        this.state = {\n            data: 'no data',\n        }\n    }\n    \n    componentWillMount() {\n        this.listener = EventRegister.addEventListener('myCustomEvent', (data) =\u003e {\n            this.setState({\n                data,\n            })\n        })\n    }\n    \n    componentWillUnmount() {\n        EventRegister.removeEventListener(this.listener)\n    }\n    \n    render() {\n        return \u003cText\u003e{this.state.data}\u003c/Text\u003e\n    }\n}\n\n/*\n * SENDER COMPONENT\n */\nconst Sender = (props) =\u003e (\n    \u003cTouchableHighlight\n        onPress={() =\u003e {\n            EventRegister.emit('myCustomEvent', 'it works!!!')\n        })\n    \u003e\u003cText\u003eSend Event\u003c/Text\u003e\u003c/TouchableHighlight\u003e\n)\n```\n\n## API\n\n```javascript\n// import\nimport { EventRegister } from 'react-native-event-listeners'\n```\n\n| static method       | return value      | description                                                    |\n| :------------------ | :---------------- | :------------------------------------------------------------- |\n| addEventListener    | string \\| boolean | return value is the id of the event listener or false on error |\n| removeEventListener | boolean           | true on success otherwise false                                |\n| removeAllListeners  | boolean           | true on success otherwise false                                |\n| emitEvent           | void              | no return value                                                |\n| on                  | string \\| boolean | **shorthand** for addEventListener                             |\n| rm                  | boolean           | **shorthand** for removeEventListener                          |\n| rmAll               | boolean           | **shorthand** for removeAllListeners                           |\n| emit                | void              | **shorthand** for emitEvent                                    |\n\n\n## Contributors\n\n### Code Contributors\n\nThis project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].\n\u003ca href=\"https://github.com/meinto/react-native-event-listeners/graphs/contributors\"\u003e\u003cimg src=\"https://opencollective.com/react-native-event-listeners/contributors.svg?width=890\u0026button=false\" /\u003e\u003c/a\u003e\n\n### Financial Contributors\n\nBecome a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/react-native-event-listeners/contribute)]\n\n#### Individuals\n\n\u003ca href=\"https://opencollective.com/react-native-event-listeners\"\u003e\u003cimg src=\"https://opencollective.com/react-native-event-listeners/individuals.svg?width=890\"\u003e\u003c/a\u003e\n\n#### Organizations\n\nSupport this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/react-native-event-listeners/contribute)]\n\n\u003ca href=\"https://opencollective.com/react-native-event-listeners/organization/0/website\"\u003e\u003cimg src=\"https://opencollective.com/react-native-event-listeners/organization/0/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/react-native-event-listeners/organization/1/website\"\u003e\u003cimg src=\"https://opencollective.com/react-native-event-listeners/organization/1/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/react-native-event-listeners/organization/2/website\"\u003e\u003cimg src=\"https://opencollective.com/react-native-event-listeners/organization/2/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/react-native-event-listeners/organization/3/website\"\u003e\u003cimg src=\"https://opencollective.com/react-native-event-listeners/organization/3/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/react-native-event-listeners/organization/4/website\"\u003e\u003cimg src=\"https://opencollective.com/react-native-event-listeners/organization/4/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/react-native-event-listeners/organization/5/website\"\u003e\u003cimg src=\"https://opencollective.com/react-native-event-listeners/organization/5/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/react-native-event-listeners/organization/6/website\"\u003e\u003cimg src=\"https://opencollective.com/react-native-event-listeners/organization/6/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/react-native-event-listeners/organization/7/website\"\u003e\u003cimg src=\"https://opencollective.com/react-native-event-listeners/organization/7/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/react-native-event-listeners/organization/8/website\"\u003e\u003cimg src=\"https://opencollective.com/react-native-event-listeners/organization/8/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/react-native-event-listeners/organization/9/website\"\u003e\u003cimg src=\"https://opencollective.com/react-native-event-listeners/organization/9/avatar.svg\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeinto%2Freact-native-event-listeners","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeinto%2Freact-native-event-listeners","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeinto%2Freact-native-event-listeners/lists"}