Coder Social home page Coder Social logo

Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type JavaScriptContextHolder? about react-native-fast-openpgp HOT 4 CLOSED

jerson avatar jerson commented on June 14, 2024
Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type JavaScriptContextHolder?

from react-native-fast-openpgp.

Comments (4)

maksimlya avatar maksimlya commented on June 14, 2024 1

Hi @jerson, these are the fixed functions:

  fun install(promise: Promise) {
    Thread {
      reactApplicationContext.runOnJSQueueThread {
        Log.d(TAG, "installing")
        try {
          val contextHolder = this.reactApplicationContext.javaScriptContextHolder!!.get()
          if (contextHolder.toInt() == 0) {
            promise.resolve(false)
            return@runOnJSQueueThread
          }
          initialize(contextHolder)
          Log.i(TAG, "successfully installed")
          promise.resolve(true)
        } catch (exception: java.lang.Exception) {
          Log.e(TAG, "failed to install JSI", exception)
          promise.reject(exception)
        }
      }
    }.start()
  }

```  @ReactMethod
  fun callJSI(name: String, payload: ReadableArray, promise: Promise) {
    Thread {
      reactApplicationContext.runOnJSQueueThread {
        try {
          val contextHolder = this.reactApplicationContext.javaScriptContextHolder!!.get()
          if (contextHolder.toInt() == 0) {
            call(name, payload, promise)
            return@runOnJSQueueThread
          }
          val bytes = ByteArray(payload.size()) { pos -> payload.getInt(pos).toByte() }
          val result = callJSI(contextHolder, name, bytes)
          val resultList = Arguments.createArray()
          for (i in result.indices) {
            resultList.pushInt(result[i].toInt())
          }
          promise.resolve(resultList)
        } catch (e: Exception) {
          promise.reject(e)
        }
      }
    }.start()
  }

from react-native-fast-openpgp.

jerson avatar jerson commented on June 14, 2024

Hi @maksimlya could you share the code for those 2 lines after you fixed please?

from react-native-fast-openpgp.

jerson avatar jerson commented on June 14, 2024

Thanks, PR was created https://github.com/jerson/react-native-fast-openpgp/pull/92/files

from react-native-fast-openpgp.

maksimlya avatar maksimlya commented on June 14, 2024

Awesome, thx alot!

from react-native-fast-openpgp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.