Skip to content

Commit

Permalink
Update implementation on native generators
Browse files Browse the repository at this point in the history
  • Loading branch information
erdemyerebasmaz committed Mar 22, 2024
1 parent 130bb38 commit 7ff53bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/gen_kotlin/templates/module.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ class BreezSDKModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
{% endif -%}
{%- endfor %}
@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
3 changes: 2 additions & 1 deletion src/gen_swift/templates/extern.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ @interface RCT_EXTERN_MODULE(RNBreezSDK, RCTEventEmitter)
{% endif %}
{%- endfor %}
RCT_EXTERN_METHOD(
setLogStream: (RCTPromiseResolveBlock)resolve
setLogStream: (NSString*)filterLevel
resolve: (RCTPromiseResolveBlock)resolve
reject: (RCTPromiseRejectBlock)reject
)

Expand Down
10 changes: 7 additions & 3 deletions src/gen_swift/templates/module.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,14 @@ class RNBreezSDK: RCTEventEmitter {
{% include "TopLevelFunctionTemplate.swift" %}
{% endif -%}
{%- endfor %}
@objc(setLogStream:reject:)
func setLogStream(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
@objc(setLogStream:resolve:reject:)
func setLogStream(_ filterLevel: String?, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
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 7ff53bb

Please sign in to comment.