SlideShare a Scribd company logo
1 of 35
Download to read offline
KISSY




KISSY Component API Design
                    yiminghe@gmail.com

                       2012-06-05 draft
KISSY
                                                      2



             Outline
•   Why create component
•   Why API design
•   KISSY Component API Design
•   API Design principles

             docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                               3



            Components




http://docs.kissyui.com/kissy-bootstrap/docs/

                      docs.kissyui.com | kissyteam@gmail.com
KISSY
                                           4



Components




  docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                     5



Why create components

• Ease of development




            docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                         6



Why create components

• Ease of development

• Reusability


                docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                         7



Why create components

• Ease of development

• Reusability

•Maintainability
                docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                        8



       Why API Design

• Contract between user and developer




               docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                         9



        Why API Design

• Contract between user and developer

• Stable platform to build on



                docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                      1
                                                                      0



            Why API Design

• Contract between user and developer

• Stable platform to build on
• Minimize waste
  •   Code-reuse instead of re-writing
  •   Reduce code and complexity


                             docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                             1
                                                             1



  Component API Design
• Structure
• Subcomponent
• Subclass
• Plugin
• Events
    • Lifecycle event
• Skin
• Creation

                    docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                        1
                                                        2



              Structure

• Config

• Attribute

• Method

               docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                             1
                                                             3



                    Config

• Config
new Overlay({
      width:100,
      height:100,
      content:'i am overlay'
})

                    docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                               1
                                                               4



                    Attribute

• Attribute
   • Talk to your component

var o=new Overlay({});
o.get("content");
o.set("content","xx");



                      docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                 1
                                                                 5



                     Method

• Method
   • Attribute first, method second

var o=new Tree({});
o.collapseAll();
o.set(“collapsed",true);



                        docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                             1
                                                             6



          Subcomponent

•Config/Attribute
  • Children



•Method
  • addChild/removeChild/removeChildren


                    docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                       1
                                                                       7



              Subcomponent

•Config/Attribute
      • Children

var o=new Menu({
children:[{new Menu.Item(){}},{xclass:'menuitem‘, content:'menuitem-
content2'}]
});
o.get("children");



                          docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                              1
                                                              8



          Subcomponent

•Method
   • addChild/removeChild/removeChildren

var o=new Menu({});
o.addChild(new Menu.Item());




                     docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                             1
                                                             9



              Subclass
                      var MyOverlay = Overlay.extend({
                                  initialize:function(){},
• Easy to extend                  createDom:function(){},
                                  renderUI:function(){},
                                  syncUI:function(){}
                      },{
                                  ATTRS:{
                                             myAttr:{}
                                  }
                      });
                   docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                   2
                                                                   0


                Plugin

• enhance ability            var editor = new Editor({
                                    plugins:[
dynamically at
                                       FontSize,
runtime                                new Image({
                                                url:’upload.htm’
                                       })]
                             });


                docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                    2
                                                                    1



                           Events
• Event
    • Native lifecycle event / attrChange event / Custom event
    • Method: on / detach
    • Config : listeners
{
type:,
target:, // consider bubbling
yy:xx
}



                           docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                           2
                                                           2



                  Events

• Custom Event
var o = new Overlay({
 listeners : { hide : { fn : function(){}}}
});
o.on("show",function(){
});

                  docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                      2
                                                                      3



                           Events

• Lifecycle event
      • beforeCreateDom/afterCreateDom/beforeRenderUI/afterRenderUI
        /beforeBindUI/afterBindUI/..

var o=new Overlay();
o.on("afterCreateDom",function(){
  alert(o.get("el"));
});

                           docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                   2
                                                                   4



                          Events

• AttrChange event
      • beforeAttrChange/afterAttrChangeDom

var o=new Button.Toggle();
o.on("afterCheckedChange",function(){
 alert(o.get(“checked"));
});


                          docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                             2
                                                             5



                          Skin

• Config
   • prefixCls

new Button({
      prefixCls:"xx-"
});



                    docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                      2
                                                      6



            Creation

• new

• srcNode

• xclass

             docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                           2
                                                           7



                Creation

• new

var m = new Menu();
m.addChild(new Menu.Item());
m.on("click",function(){})
m.render();


                  docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                                           2
                                                                           8



                  Creation

• srcNode                                   new Menu({
                                                 srcNode:div,
<div class='ks-menu'>                            listeners:{
<div class='ks-                                        click:function(){
  menuitem'></div>                                     }
</div>                                           }
                                            });

                     docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                           2
                                                           9



             Creation
           new Menu({
• xclass    children:[{
              xclass:'menuitem',
              content:'yy'
            }],
            render:container,
            listeners:{
              click:function(){}
           }});
                  docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                           3
                                                           0



      API Design Principle

• Hide implementation

new Overlay({
// view: new OverlayRender()
});



                  docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                           3
                                                           1



    API Design Principle

• Easy to learn
  • consistency
  • simple


• elCls/el/srcNode/get()/set()

                  docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                           3
                                                           2



    API Design Principle

• Easy to read and write
new Overlay({
  width:,
  height:'',
  children:[{
  xclass:'menu'
}]});

                  docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                            3
                                                            3



    API Design Principle

• Easy to extend


var MyOverlay = Overlay.extend(…);


                   docs.kissyui.com | kissyteam@gmail.com
KISSY
                                                           3
                                                           4



     API Design Principle

• make api complete
• separate concern


• new/addChild/removeChild/destroy/on/detach


                  docs.kissyui.com | kissyteam@gmail.com
KISSY




THANKS FOR
  COMING
   SEE YOU SOON!

More Related Content

More from yiming he

KISSY 1.4.0 released
KISSY 1.4.0 releasedKISSY 1.4.0 released
KISSY 1.4.0 releasedyiming he
 
callSuper in kissy
callSuper in kissycallSuper in kissy
callSuper in kissyyiming he
 
KISSY XTemplate
KISSY XTemplateKISSY XTemplate
KISSY XTemplateyiming he
 
Introduction to kissy for adc 2013
Introduction to kissy for adc 2013Introduction to kissy for adc 2013
Introduction to kissy for adc 2013yiming he
 
Kissy component system
Kissy component systemKissy component system
Kissy component systemyiming he
 
KISSY@2013.05
KISSY@2013.05KISSY@2013.05
KISSY@2013.05yiming he
 
kissy@2013.03
kissy@2013.03 kissy@2013.03
kissy@2013.03 yiming he
 
KISSY 1.3-released
KISSY 1.3-releasedKISSY 1.3-released
KISSY 1.3-releasedyiming he
 
Simple kissy1.3
Simple kissy1.3Simple kissy1.3
Simple kissy1.3yiming he
 
Kissy in-progress
Kissy in-progressKissy in-progress
Kissy in-progressyiming he
 
Kissy dpl-practice
Kissy dpl-practiceKissy dpl-practice
Kissy dpl-practiceyiming he
 
编辑器设计2
编辑器设计2编辑器设计2
编辑器设计2yiming he
 
KISSY Editor Design 2
KISSY Editor Design 2KISSY Editor Design 2
KISSY Editor Design 2yiming he
 
Kissy autocomplete
Kissy autocompleteKissy autocomplete
Kissy autocompleteyiming he
 
KISSY_Component
KISSY_ComponentKISSY_Component
KISSY_Componentyiming he
 
How to reduce connections with kissy
How to reduce connections with kissyHow to reduce connections with kissy
How to reduce connections with kissyyiming he
 
Caja "Ka-ha" Introduction
Caja "Ka-ha" IntroductionCaja "Ka-ha" Introduction
Caja "Ka-ha" Introductionyiming he
 

More from yiming he (20)

KISSY 1.4.0 released
KISSY 1.4.0 releasedKISSY 1.4.0 released
KISSY 1.4.0 released
 
callSuper in kissy
callSuper in kissycallSuper in kissy
callSuper in kissy
 
KISSY XTemplate
KISSY XTemplateKISSY XTemplate
KISSY XTemplate
 
Introduction to kissy for adc 2013
Introduction to kissy for adc 2013Introduction to kissy for adc 2013
Introduction to kissy for adc 2013
 
Kissy component system
Kissy component systemKissy component system
Kissy component system
 
KISSY@2013.05
KISSY@2013.05KISSY@2013.05
KISSY@2013.05
 
kissy@2013.03
kissy@2013.03 kissy@2013.03
kissy@2013.03
 
kissy@2013
kissy@2013kissy@2013
kissy@2013
 
KISSY 1.3-released
KISSY 1.3-releasedKISSY 1.3-released
KISSY 1.3-released
 
Simple kissy1.3
Simple kissy1.3Simple kissy1.3
Simple kissy1.3
 
Hujs 总结
Hujs 总结Hujs 总结
Hujs 总结
 
Kissy in-progress
Kissy in-progressKissy in-progress
Kissy in-progress
 
Kissy dpl-practice
Kissy dpl-practiceKissy dpl-practice
Kissy dpl-practice
 
编辑器设计2
编辑器设计2编辑器设计2
编辑器设计2
 
KISSY Editor Design 2
KISSY Editor Design 2KISSY Editor Design 2
KISSY Editor Design 2
 
Kissy autocomplete
Kissy autocompleteKissy autocomplete
Kissy autocomplete
 
KISSY_Component
KISSY_ComponentKISSY_Component
KISSY_Component
 
How to reduce connections with kissy
How to reduce connections with kissyHow to reduce connections with kissy
How to reduce connections with kissy
 
Kissy mvc
Kissy mvcKissy mvc
Kissy mvc
 
Caja "Ka-ha" Introduction
Caja "Ka-ha" IntroductionCaja "Ka-ha" Introduction
Caja "Ka-ha" Introduction
 

Recently uploaded

A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 

Recently uploaded (20)

A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 

KISSY Component API Design

  • 1. KISSY KISSY Component API Design yiminghe@gmail.com 2012-06-05 draft
  • 2. KISSY 2 Outline • Why create component • Why API design • KISSY Component API Design • API Design principles docs.kissyui.com | kissyteam@gmail.com
  • 3. KISSY 3 Components http://docs.kissyui.com/kissy-bootstrap/docs/ docs.kissyui.com | kissyteam@gmail.com
  • 4. KISSY 4 Components docs.kissyui.com | kissyteam@gmail.com
  • 5. KISSY 5 Why create components • Ease of development docs.kissyui.com | kissyteam@gmail.com
  • 6. KISSY 6 Why create components • Ease of development • Reusability docs.kissyui.com | kissyteam@gmail.com
  • 7. KISSY 7 Why create components • Ease of development • Reusability •Maintainability docs.kissyui.com | kissyteam@gmail.com
  • 8. KISSY 8 Why API Design • Contract between user and developer docs.kissyui.com | kissyteam@gmail.com
  • 9. KISSY 9 Why API Design • Contract between user and developer • Stable platform to build on docs.kissyui.com | kissyteam@gmail.com
  • 10. KISSY 1 0 Why API Design • Contract between user and developer • Stable platform to build on • Minimize waste • Code-reuse instead of re-writing • Reduce code and complexity docs.kissyui.com | kissyteam@gmail.com
  • 11. KISSY 1 1 Component API Design • Structure • Subcomponent • Subclass • Plugin • Events • Lifecycle event • Skin • Creation docs.kissyui.com | kissyteam@gmail.com
  • 12. KISSY 1 2 Structure • Config • Attribute • Method docs.kissyui.com | kissyteam@gmail.com
  • 13. KISSY 1 3 Config • Config new Overlay({ width:100, height:100, content:'i am overlay' }) docs.kissyui.com | kissyteam@gmail.com
  • 14. KISSY 1 4 Attribute • Attribute • Talk to your component var o=new Overlay({}); o.get("content"); o.set("content","xx"); docs.kissyui.com | kissyteam@gmail.com
  • 15. KISSY 1 5 Method • Method • Attribute first, method second var o=new Tree({}); o.collapseAll(); o.set(“collapsed",true); docs.kissyui.com | kissyteam@gmail.com
  • 16. KISSY 1 6 Subcomponent •Config/Attribute • Children •Method • addChild/removeChild/removeChildren docs.kissyui.com | kissyteam@gmail.com
  • 17. KISSY 1 7 Subcomponent •Config/Attribute • Children var o=new Menu({ children:[{new Menu.Item(){}},{xclass:'menuitem‘, content:'menuitem- content2'}] }); o.get("children"); docs.kissyui.com | kissyteam@gmail.com
  • 18. KISSY 1 8 Subcomponent •Method • addChild/removeChild/removeChildren var o=new Menu({}); o.addChild(new Menu.Item()); docs.kissyui.com | kissyteam@gmail.com
  • 19. KISSY 1 9 Subclass var MyOverlay = Overlay.extend({ initialize:function(){}, • Easy to extend createDom:function(){}, renderUI:function(){}, syncUI:function(){} },{ ATTRS:{ myAttr:{} } }); docs.kissyui.com | kissyteam@gmail.com
  • 20. KISSY 2 0 Plugin • enhance ability var editor = new Editor({ plugins:[ dynamically at FontSize, runtime new Image({ url:’upload.htm’ })] }); docs.kissyui.com | kissyteam@gmail.com
  • 21. KISSY 2 1 Events • Event • Native lifecycle event / attrChange event / Custom event • Method: on / detach • Config : listeners { type:, target:, // consider bubbling yy:xx } docs.kissyui.com | kissyteam@gmail.com
  • 22. KISSY 2 2 Events • Custom Event var o = new Overlay({ listeners : { hide : { fn : function(){}}} }); o.on("show",function(){ }); docs.kissyui.com | kissyteam@gmail.com
  • 23. KISSY 2 3 Events • Lifecycle event • beforeCreateDom/afterCreateDom/beforeRenderUI/afterRenderUI /beforeBindUI/afterBindUI/.. var o=new Overlay(); o.on("afterCreateDom",function(){ alert(o.get("el")); }); docs.kissyui.com | kissyteam@gmail.com
  • 24. KISSY 2 4 Events • AttrChange event • beforeAttrChange/afterAttrChangeDom var o=new Button.Toggle(); o.on("afterCheckedChange",function(){ alert(o.get(“checked")); }); docs.kissyui.com | kissyteam@gmail.com
  • 25. KISSY 2 5 Skin • Config • prefixCls new Button({ prefixCls:"xx-" }); docs.kissyui.com | kissyteam@gmail.com
  • 26. KISSY 2 6 Creation • new • srcNode • xclass docs.kissyui.com | kissyteam@gmail.com
  • 27. KISSY 2 7 Creation • new var m = new Menu(); m.addChild(new Menu.Item()); m.on("click",function(){}) m.render(); docs.kissyui.com | kissyteam@gmail.com
  • 28. KISSY 2 8 Creation • srcNode new Menu({ srcNode:div, <div class='ks-menu'> listeners:{ <div class='ks- click:function(){ menuitem'></div> } </div> } }); docs.kissyui.com | kissyteam@gmail.com
  • 29. KISSY 2 9 Creation new Menu({ • xclass children:[{ xclass:'menuitem', content:'yy' }], render:container, listeners:{ click:function(){} }}); docs.kissyui.com | kissyteam@gmail.com
  • 30. KISSY 3 0 API Design Principle • Hide implementation new Overlay({ // view: new OverlayRender() }); docs.kissyui.com | kissyteam@gmail.com
  • 31. KISSY 3 1 API Design Principle • Easy to learn • consistency • simple • elCls/el/srcNode/get()/set() docs.kissyui.com | kissyteam@gmail.com
  • 32. KISSY 3 2 API Design Principle • Easy to read and write new Overlay({ width:, height:'', children:[{ xclass:'menu' }]}); docs.kissyui.com | kissyteam@gmail.com
  • 33. KISSY 3 3 API Design Principle • Easy to extend var MyOverlay = Overlay.extend(…); docs.kissyui.com | kissyteam@gmail.com
  • 34. KISSY 3 4 API Design Principle • make api complete • separate concern • new/addChild/removeChild/destroy/on/detach docs.kissyui.com | kissyteam@gmail.com
  • 35. KISSY THANKS FOR COMING SEE YOU SOON!