callsuper in kissy

14
callSuper in KISSY [email protected] 承玉

Post on 12-Sep-2014

275 views

Category:

Technology


1 download

DESCRIPTION

implement super in KISSY

TRANSCRIPT

Page 1: callSuper in kissy

callSuper in KISSY

[email protected]

承玉

Page 2: callSuper in kissy

Super

• Call super class method from sub class method with same signature.

Page 3: callSuper in kissy

Super in other language

• Java

• constructor default super()

– keyword

base() sub()

Page 4: callSuper in kissy

Super in other language

• Java

• Constructor Explicit call super

– Must be on first line

– keyword

base(int i) sub()

Page 5: callSuper in kissy

Super in other languages

• Java

• Explicit call super.xx in overriden method

– object

sub run() base run()

Page 6: callSuper in kissy

Super in other languages

• Python

• Super

– Build-in bind function( mro )

– Constructor is same with method

• No first line constraint

• Allow multiple inheritance

Base init Sub init Sub run Base run

Page 7: callSuper in kissy

Super in other languages

• JavaScript

• But flexible

Page 8: callSuper in kissy

Super in KISSY

• KISSY

– Build own class system

Page 9: callSuper in kissy

Super in KISSY

• callSuper

• Built-in bind function (~python)

• No need to specify method name

• Does not allow multiple inheritance – Extensions(Mixins) + single Inheritance + plugin

Page 10: callSuper in kissy

Usage

Base init M1 init Sub init Sub run Base run Sub destroy M1 destroy Base destroy

Page 11: callSuper in kissy

Bind usage

• Closure?

Page 12: callSuper in kissy

internal

• arguments.callee.caller

• __owner__/__name__

Page 14: callSuper in kissy

Acknowledgements

• goto100(义宇)