Skip to content

Commit

Permalink
fix: workaround to init memory
Browse files Browse the repository at this point in the history
  • Loading branch information
zpv committed Feb 19, 2021
1 parent 765f39b commit f38a90f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
21 changes: 5 additions & 16 deletions ios/Cfddlc.swift
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
import Foundation
import WebKit

let queue = DispatchQueue(label: "cfddlc-queue", qos: .userInitiated, attributes: .concurrent)

func handleCfddlcCall(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock, operation: @escaping () -> String) {
queue.async {
let response = operation()
resolve(response)
}
}

let queue = DispatchQueue(label: "cfddlc-queue", qos: .userInitiated, attributes: .concurrent)

extension DispatchQueue {
static func background(delay: Double = 0.0, background: (()->Void)? = nil, completion: (() -> Void)? = nil) {
queue.async {
background?()
if let completion = completion {
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: {
completion()
})
}
}
}

}

@objc(Cfddlc)
class Cfddlc: NSObject {
@objc static func requiresMainQueueSetup() -> Bool {
Expand All @@ -33,6 +19,9 @@ class Cfddlc: NSObject {
override init() {
super.init()
CfddlcBridge().initialize()

// ??: prevents some crashes from occurring
CfddlcBridge().createCetAdaptorSignatures("{}")
}

@objc
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-native-cfddlc",
"title": "react-native-cfddlc",
"version": "0.0.4",
"version": "0.0.5",
"description": "React Native module for cfd-dlc",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
Expand Down

0 comments on commit f38a90f

Please sign in to comment.