turansky
02/06/2017, 7:28 PMinterface A {
fun doOne() // must be overrided
fun doTwo() = definedExternally
}
class B: A {
override fun doOne() { // do something }
class C: A {
override fun doOne() { // do something }
}
bashor
02/06/2017, 8:19 PMA
be external
interface in your case?bashor
02/06/2017, 8:21 PMinterface A
with “optional” function?bashor
02/07/2017, 10:09 AMturansky
02/07/2017, 11:31 AMA
must be externalturansky
02/07/2017, 11:36 AMturansky
02/07/2017, 11:38 AMturansky
02/07/2017, 11:43 AMaimozg
02/07/2017, 12:16 PMkonsoletyper
02/07/2017, 12:25 PMdoOne
as a member method?turansky
02/07/2017, 12:27 PMdoTwo()
already realized externallyturansky
02/07/2017, 12:27 PMdoOne
turansky
02/07/2017, 12:29 PMexternal interface A {
fun doOne() // must be overrided
fun doTwo() = definedExternally
}
external open class B: A {
override fun doOne() { // do something }
external open class C: A {
override fun doOne() { // do something }
}
turansky
02/07/2017, 12:29 PMfun doTwo() = definedExternally
will not be compiledturansky
02/07/2017, 12:30 PMA
already realize this methodaimozg
02/07/2017, 12:30 PMinterface A
or class B
?aimozg
02/07/2017, 12:32 PMturansky
02/07/2017, 12:32 PMturansky
02/07/2017, 12:32 PMaimozg
02/07/2017, 12:32 PMturansky
02/07/2017, 12:33 PMturansky
02/07/2017, 12:37 PMbashor
02/07/2017, 1:04 PM@JsName("A")
external class AImpl
val protoA = AImpl::class.js.asDynamic().prototype
interface A {
fun foo()
fun bar(a: Int) = protoA.bar.call(this, a)
// or
fun baz(b: Int) = js("A.prototype.baz.call(this, b)")
// or
fun boo(b: Int) = js("A.prototype.baz.call(this, arguments)")
}
turansky
02/07/2017, 1:16 PMfile:JsModule(”modules/A.js")
?bashor
02/07/2017, 1:18 PMbashor
02/07/2017, 1:21 PMturansky
02/07/2017, 1:31 PMbar
realization use foo
implementation?turansky
02/07/2017, 1:32 PMbashor
02/07/2017, 1:44 PM// mix from object
external interface A {
fun bar(a: Int)
}
external val b: A
class D : A by b
// mix from A.prototype
@JsName("A")
external class AIMpl
val p: A AIMpl::class.js.asDynamic().prototype
class E : A by p
bashor
02/07/2017, 1:46 PMIt also will work?I think yes. Just try 🙂
turansky
02/07/2017, 7:07 PMExternal type extends non-external type
turansky
02/07/2017, 7:08 PM@JsName("A")
external class AImpl
val protoA = AImpl::class.js.asDynamic().prototype
interface A {
fun foo()
fun bar(a: Int) = protoA.bar.call(this, a)
external class B: A { // ERROR IS HERE
}
bashor
02/07/2017, 7:13 PMturansky
02/07/2017, 7:17 PMturansky
02/07/2017, 7:18 PM// mix from object
external interface A {
fun bar(a: Int)
}
external val b: A
// mix from A.prototype
class D : A by b
This is first solution?bashor
02/07/2017, 7:22 PMbashor
02/07/2017, 7:23 PMturansky
02/07/2017, 7:23 PM// mix from object
external interface A {
fun barA(a: Int)
}
external interface B {
fun barB(a: Int)
}
external val AImpl: A
external val BImpl: B
// mix from A.prototype
external class D : A by AImpl, B by BImpl
In such case I have error - Can’t use delegate on external class
bashor
02/07/2017, 7:24 PMbashor
02/07/2017, 7:24 PMbashor
02/07/2017, 7:25 PMA
and B
to D
itself?bashor
02/07/2017, 7:25 PMexternal class D : A, B
bashor
02/07/2017, 7:26 PMturansky
02/07/2017, 7:27 PMturansky
02/07/2017, 7:28 PMturansky
02/07/2017, 7:29 PMIList
turansky
02/07/2017, 7:29 PMturansky
02/07/2017, 7:32 PMturansky
02/07/2017, 7:33 PMbashor
02/07/2017, 7:38 PMbashor
02/07/2017, 7:38 PMturansky
02/07/2017, 7:55 PMturansky
02/07/2017, 7:58 PMturansky
02/07/2017, 7:59 PMTable
realization must be overrided only abstract methods.turansky
02/07/2017, 8:02 PMITable
methods are already implementedaimozg
02/07/2017, 8:03 PMinterface
and not just superclass?turansky
02/07/2017, 8:03 PMMyTable
realization I want to implement only methods marked like abstract
turansky
02/07/2017, 8:07 PMthen why you need anIn this case I will not have ability to implement multiple interfacesand not just superclass?interface
aimozg
02/07/2017, 8:12 PMaimozg
02/07/2017, 8:12 PMturansky
02/07/2017, 8:13 PMturansky
02/07/2017, 8:16 PMturansky
02/07/2017, 9:25 PMturansky
02/08/2017, 10:21 AMturansky
02/08/2017, 10:24 AMturansky
02/08/2017, 7:04 PMbashor
02/08/2017, 7:11 PMturansky
02/09/2017, 7:11 PMturansky
02/15/2017, 10:30 PMturansky
02/17/2017, 5:49 PMbashor
02/17/2017, 6:29 PMturansky
02/18/2017, 10:09 AMbashor
02/20/2017, 6:06 PMITable
declared as interface so for TypeScript it’s some declaration which exist only at compile time.bashor
02/20/2017, 6:07 PMITable
bashor
02/20/2017, 6:12 PMbashor
02/20/2017, 6:47 PMkotlin
// FILE: d.kt
@file:JsQualifier("yfiles.graph")
package yfiles.graph
external interface ITable {
fun foo()
fun bar() = 2
}
@JsName("ITable")
external class ITableImpl
// FILE: d2.kt
@file:JsQualifier("yfiles.lang")
package yfiles.lang
external class Class {
val prototype: dynamic
}
// FILE: usage.kt
class MyTable : ITable by ITableImpl::class.js.asDynamic().prototype
class MyTable2 : ITable by yfiles.lang.Class(ITableImpl::class.js).prototype
bashor
02/20/2017, 6:47 PMbashor
02/20/2017, 6:48 PMyfiles.lang.BaseClass
turansky
02/21/2017, 12:01 PMclass MyTable : ITable by ITableImpl::class.js.asDynamic().prototypeclass MyTable : ITable by ITableImpl::class.js.asDynamic().prototype
I will try in any case.
In geometry
package exists classes, which implements 2 or 3 traits.
For example http://docs.yworks.com/yfileshtml/#/api/yfiles.geometry.OrientedRectangle. Such classes also can be realized, right?bashor
02/22/2017, 4:23 PMIn this example only I will need declare only nonimplemented methods?Yes, I think it should work, but it will not force you to implement all members
bashor
02/22/2017, 4:25 PMInLooks like inheritance from classes should work out of boxpackage exists classes, which implements 2 or 3 traits.geometry