Skip to content

Commit

Permalink
Generate RN Bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
erdemyerebasmaz committed Mar 28, 2024
1 parent eeb133d commit a16f6d0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,16 @@ class BreezSDKModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
}

@ReactMethod
fun setLogStream(promise: Promise) {
fun setLogStream(
filterLevel: String?,
promise: Promise,
) {
executor.execute {
try {
val emitter = reactApplicationContext.getJSModule(RCTDeviceEventEmitter::class.java)
val levelFilter = filterLevel?.let { asLevelFilter(filterLevel) }

setLogStream(BreezSDKLogStream(emitter))
setLogStream(BreezSDKLogStream(emitter), levelFilter)
promise.resolve(readableMapOf("status" to "ok"))
} catch (e: Exception) {
e.printStackTrace()
Expand Down
2 changes: 1 addition & 1 deletion libs/sdk-react-native/example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const App = () => {

const asyncFn = async () => {
try {
logSubscription = await setLogStream(logHandler)
logSubscription = await setLogStream(logHandler, null)

let mnemonic = await getSecureItem(MNEMONIC_STORE)

Expand Down
3 changes: 2 additions & 1 deletion libs/sdk-react-native/ios/RNBreezSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ @interface RCT_EXTERN_MODULE(RNBreezSDK, RCTEventEmitter)
)

RCT_EXTERN_METHOD(
setLogStream: (RCTPromiseResolveBlock)resolve
setLogStream: (NSString*)filterLevel
resolve: (RCTPromiseResolveBlock)resolve
reject: (RCTPromiseRejectBlock)reject
)

Expand Down
10 changes: 7 additions & 3 deletions libs/sdk-react-native/ios/RNBreezSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,14 @@ class RNBreezSDK: RCTEventEmitter {
}
}

@objc(setLogStream:reject:)
func setLogStream(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
@objc(setLogStream:resolve:reject:)
func setLogStream(_ filterLevel: String?, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
do {
try BreezSDK.setLogStream(logStream: BreezSDKLogStream())
var levelFilter: LevelFilter? = nil
if filterLevel != nil {
levelFilter = try BreezSDKMapper.asLevelFilter(levelFilter: filterLevel!)
}
try BreezSDK.setLogStream(logStream: BreezSDKLogStream(), filterLevel: levelFilter)
resolve(["status": "ok"])
} catch let err {
rejectErr(err: err, reject: reject)
Expand Down

0 comments on commit a16f6d0

Please sign in to comment.