Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Shared event emitter between native and JS for React Native.

License

NotificationsYou must be signed in to change notification settings

paramaggarwal/react-native-global-event-emitter

Repository files navigation

Shared event emitter between native and JS for React Native.

Uses iOSNotificationCenter and RNDeviceEventEmitter to provide a seamless global event bus between native and React Native.

Screenshot

Screenshot of the example app

Usage

// listen to event posted to NSNotificationCenter by native codevareventName=GlobalEventEmitter.UIApplicationNotifications.UIApplicationDidEnterBackgroundNotification;GlobalEventEmitter.addListener(eventName,(data)=>{console.log('UIApplicationDidEnterBackgroundNotification');});// event available on NSNotificationCenter for native codevareventName="UserDidLoginFromJS"GlobalEventEmitter.emit(eventName,{name:'John'});

Properties

  • addListener: Add a listener for aneventName and pass acallback function.
  • emit: Emit events to native/JS globally.
  • removeListener: Remove a listener by passing theeventName and the reference to the originalcallback function.
  • removeAllListeners: Stop listening to all events of a particulareventName.

Installation

Use your preferred method of including the library in your app.

Example

Try the included example:

git clone git@github.com:paramaggarwal/react-native-global-event-emitter.gitnpm installopen iOS/RNTGlobalEventEmitter.xcodeproj

ThenCmd+R to start the React Packager, build and run the project in the simulator.

Author

Param Aggarwal (paramaggarwal@gmail.com)

License

MIT License

About

Shared event emitter between native and JS for React Native.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors4

  •  
  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp