-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for all interface attributes (#3)
* Repleace release-it with auto * Update ci.yml * Set access public * Create empty CHANGELOG.md file * Add scan job with trivy * Fix CI actions * Upgrade babel-plugin-module-resolver to fix json5 vulnerability * Skip scan node_modules directory * Fix buyerId prop type * Pass debugMode prop * Update example app README with cache reset info * Update default GR4VY_ID in .env.example * Add externalIdentifier prop support * Add other props and attempt to properly type paymentSource * Add cartItems prop * Add cartItems typing on the js side * Add paymentSource and cartItems type conversions * Remove previous cartItems map * Fix Android params * Use Native Event Emitter in iOS * Attempt to add the same `onEvent` logging to the Android part * Fix events handling in android * Remove any onEvent listener before adding a new one * Clean up android code * Set default buyerId to null in example app
- Loading branch information
1 parent
bb5f025
commit 7e49ed1
Showing
13 changed files
with
300 additions
and
78 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
android/src/main/java/com/gr4vy/embedreactnative/EmbedReactNativeEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.gr4vy.embedreactnative; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import com.facebook.react.modules.core.DeviceEventManagerModule; | ||
import com.facebook.react.bridge.WritableMap; | ||
import com.facebook.react.bridge.Arguments; | ||
import com.facebook.react.bridge.ReactContext; | ||
import com.facebook.react.bridge.ReactMethod; | ||
|
||
public class EmbedReactNativeEvents { | ||
public static void sendEvent( | ||
ReactContext reactContext, | ||
String eventName, | ||
@Nullable WritableMap params | ||
) { | ||
reactContext | ||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) | ||
.emit(eventName, params); | ||
} | ||
|
||
private int listenerCount = 0; | ||
|
||
@ReactMethod | ||
public void addListener(String eventName) { | ||
if (listenerCount == 0) { | ||
// Set up any upstream listeners or background tasks as necessary | ||
} | ||
|
||
listenerCount += 1; | ||
} | ||
|
||
@ReactMethod | ||
public void removeListeners(Integer count) { | ||
listenerCount -= count; | ||
if (listenerCount == 0) { | ||
// Remove upstream listeners, stop unnecessary background tasks | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
GR4VY_ID=dev | ||
GR4VY_ID=spider | ||
TOKEN= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#import <React/RCTBridgeModule.h> | ||
#import <React/RCTUtils.h> | ||
#import <React/RCTEventEmitter.h> | ||
#import <React/RCTConvert.h> | ||
#import "RCTCartItem.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.