Gunslingor
08/24/2020, 4:39 PM// Simple warn notifier
var origWarn = console.warn;
toastr.options = {
closeButton: true,
preventDuplicates: true,
showDuration: 250,
hideDuration: 150
};
console.warn = function (msg) {
if (msg.indexOf('[undefined]') == -1) {
toastr.warning(msg);
}
origWarn(msg);
};
Big Chungus
08/24/2020, 6:44 PMGunslingor
08/24/2020, 6:55 PM/**
* Exposes the [console API](<https://developer.mozilla.org/en/DOM/console>) to Kotlin.
*/
@Suppress("NOT_DOCUMENTED")
public external interface Console {
public fun dir(o: Any): Unit
public fun error(vararg o: Any?): Unit
public fun info(vararg o: Any?): Unit
public fun log(vararg o: Any?): Unit
public fun warn(vararg o: Any?): Unit
}
/**
* Exposes the [console API](<https://developer.mozilla.org/en/DOM/console>) to Kotlin.
*/
public external val console: Console
Gunslingor
08/24/2020, 6:57 PMconsole.warn = function (msg) {}
Kotlin doesnt seem to allow it.. thinks warn should be warn() and then doesn't get the reassignment.Gunslingor
08/24/2020, 7:17 PMBig Chungus
08/24/2020, 7:26 PMGunslingor
08/24/2020, 7:47 PMGunslingor
08/24/2020, 7:53 PMoverride external val console: Notifier
but can't =(Big Chungus
08/24/2020, 7:57 PMGunslingor
08/24/2020, 7:57 PMBig Chungus
08/24/2020, 7:57 PMfun Console.log() = ...
Big Chungus
08/24/2020, 7:57 PMGunslingor
08/24/2020, 8:03 PMkotlin.js.console
which is a bunch of externals... so I'd be trying to extend a library of external declarations, one val and one interface. The only way to extend the interface would be to create a NEW class (since its an interface, i think) and inherit from it which I did... but it doesn't need extension it needs to be override, which I did... but I still run against the same problem, reassign the JS console functions.
To clarify: The goal here is to be able to see Toastr alerts AND console warnings for ALL console warnings submitted BY ANYTHING, not just my code 😃Big Chungus
08/24/2020, 8:06 PMBig Chungus
08/24/2020, 8:06 PMGunslingor
08/24/2020, 8:08 PMGunslingor
08/24/2020, 8:08 PMGunslingor
08/24/2020, 8:09 PMBig Chungus
08/24/2020, 8:09 PMGunslingor
08/24/2020, 8:10 PMBig Chungus
08/24/2020, 8:10 PMBig Chungus
08/24/2020, 8:10 PMGunslingor
08/24/2020, 8:12 PMGunslingor
08/24/2020, 8:22 PM