tradingview/lightweight-charts-android

The `ChartApiDelegate` `removeSeries` method's `onSeriesDeleted` callback is not called

C-Radu-V opened this issue · 0 comments

Correct me if I'm wrong, I may be missing something, but from what I see, it seems like

override fun removeSeries(seriesApi: SeriesApi, onSeriesDeleted: () -> Unit) {
        if (seriesApi is ChartRuntimeObject) {
            assert(seriesApi.getVersion() == getVersion()) {
                "The object should be removed by the same ChartApi as it was created"
            }
        }

        controller.callFunction(
            REMOVE_SERIES,
            mapOf(SERIES_UUID to seriesApi.uuid),
            onSeriesDeleted
        )
}

calls

fun callFunction(
        name: String,
        params: Map<String, Any> = emptyMap(),
        callback: (() -> Unit)?
    ): String {
        @Suppress("UNCHECKED_CAST")
        return callBridgeFunction(name, params, callback as? (Any?) -> Unit)
    }

in which case callback as? (Any?) -> Unit will cause the callBridgeFunction to be called with null callback parameter.