Hello. I have the following class. I would like to...
# javascript
a
Hello. I have the following class. I would like to do a @JsExport on it, but unfortunately SingleWrapper from the badoo.reaktive library does not support that. I though I'd wrap this class and/or method and expose something that is compatible, but I was unable to find a reactive programming kotlin library for JS. I am unsure what the best approach for this is. How does one export a Singe or Observable or ... whatever ... to JS ? I'm using binary.library() and nodejs() ... I need to have this method be called from an existing react web app, separate from this project. Any suggestions? 😞
Copy code
class SharedBookService {

    private val bookRepository = BookRepository()

    /**
     * @return an array of book permanent ids
     */
    fun getAssignedBooks(): SingleWrapper<List<String>> {
        return singleFromCoroutine {
            bookRepository.callAssignedBooks()
        }
            .subscribeOn(ioScheduler)
            .observeOn(mainScheduler)
            .onErrorReturn { t ->
                Console.apiError.log("getAssignedBooks :: " + t.message)
                listOf()
            }
            .wrap()
    }
}
And yes, the List will also be an issue, but that I know how to wrap and ajust...the Single ... not so much 😞
c
An observable that returns a single result is
Promise
in JS