andylamax
06/15/2022, 1:11 PMBig Chungus
06/15/2022, 1:14 PMeygraber
06/15/2022, 1:17 PMjw
06/15/2022, 1:36 PMjw
06/15/2022, 1:37 PMBig Chungus
06/15/2022, 1:39 PMjw
06/15/2022, 1:39 PMandylamax
06/15/2022, 1:47 PMjw
06/15/2022, 1:48 PMandylamax
06/15/2022, 1:52 PMBig Chungus
06/15/2022, 1:54 PMBig Chungus
06/15/2022, 1:55 PMjw
06/15/2022, 1:55 PMjw
06/15/2022, 1:56 PMandylamax
06/15/2022, 2:01 PMsuspend
functions are very unforgiving in kotlin/js world, the more you have them the worse it gets. Using ktor requires you to create suspend functions to call them which makes the bundle larger and largerBig Chungus
06/15/2022, 2:09 PMandylamax
06/15/2022, 2:11 PMclass AdderCoroutine {
suspend fun one() = 1
suspend fun two() = one() + 1
}
it compiles down to
$twoCOROUTINE$0.prototype = Object.create(CoroutineImpl.prototype);
$twoCOROUTINE$0.prototype.constructor = $twoCOROUTINE$0;
//endregion
function $twoCOROUTINE$0(_this__1828080292, resultContinuation) {
CoroutineImpl.call(this, resultContinuation);
this._this__1828080292__1 = _this__1828080292;
}
$twoCOROUTINE$0.prototype.doResume_5yljmg_k$ = function () {
var suspendResult = this._get_result__3382885006_f31376_k$();
$sm: do
try {
var tmp = this._get_state__3614753120_b8zcm8_k$();
switch (tmp) {
case 0:
this._set_exceptionState__118868437_8fc1n_k$(2);
this._set_state__1256591060_i39zdo_k$(1);
suspendResult = this._this__1828080292__1.one_tuyife_k$(this);
if (suspendResult === _get_COROUTINE_SUSPENDED__2870145053()) {
return suspendResult;
}
continue $sm;
case 1:
var ARGUMENT = suspendResult;
return ARGUMENT + 1 | 0;
case 2:
throw this._get_exception__1672948706_ro13he_k$();
}
} catch ($p) {
if (this._get_exceptionState__1662596297_rhv7ih_k$() === 2) {
throw $p;
} else {
this._set_state__1256591060_i39zdo_k$(this._get_exceptionState__1662596297_rhv7ih_k$());
this._set_exception__4196179798_3fu58l_k$($p);
}
}
while (true);
};
$twoCOROUTINE$0.$metadata$ = {
simpleName: '$twoCOROUTINE$0',
kind: 'class',
interfaces: []
};
function AdderCoroutine() {
}
AdderCoroutine.prototype.one_tuyife_k$ = function ($cont) {
return 1;
};
AdderCoroutine.prototype.two_hxbbm8_k$ = function ($cont) {
var tmp = new $twoCOROUTINE$0(this, $cont);
tmp._set_result__3294305178_cat9z_k$(Unit_getInstance());
tmp._set_exception__4196179798_3fu58l_k$(null);
return tmp.doResume_5yljmg_k$();
};
AdderCoroutine.$metadata$ = {
simpleName: 'AdderCoroutine',
kind: 'class',
interfaces: []
};
Big Chungus
06/15/2022, 2:12 PMandylamax
06/15/2022, 2:15 PMclass AdderPromise {
fun one(): Promise<Int> = Promise.resolve(1)
fun two(): Promise<Int> = one().then { it + 1 }
}
compiles down to
function AdderPromise$one$lambda() {
return function () {
return 1;
};
}
function AdderPromise$two$lambda() {
return function (it) {
return it + 1 | 0;
};
}
function AdderPromise() {
}
AdderPromise.prototype.one_2d0m_k$ = function () {
return promise(AdderPromise$one$lambda());
};
AdderPromise.prototype.two_2gy4_k$ = function () {
var tmp = this.one_2d0m_k$();
return then(tmp, AdderPromise$two$lambda());
};
AdderPromise.$metadata$ = {
simpleName: 'AdderPromise',
kind: 'class',
interfaces: []
};
jw
06/15/2022, 2:15 PMandylamax
06/15/2022, 2:16 PMRobert Jaros
06/15/2022, 2:29 PMandylamax
06/15/2022, 2:33 PMRobert Jaros
06/15/2022, 2:38 PMandylamax
06/15/2022, 2:42 PMRobert Jaros
06/15/2022, 2:46 PMGrégory Lureau
06/15/2022, 3:51 PM