Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
YUI3 EventTarget
Search
ningzbruc
January 24, 2013
Technology
69
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
YUI3 EventTarget
This presentation shows how YUI3 Custom Event System works!
ningzbruc
January 24, 2013
More Decks by ningzbruc
See All by ningzbruc
如何写出一个优秀的开源库
ningzbruc
0
68
去啊无线前端的一天
ningzbruc
1
210
React & Component
ningzbruc
0
65
阿里旅行去啊H5首页总结&Promise
ningzbruc
0
280
KISSY.Base - all about that Base
ningzbruc
0
150
Hammer.js
ningzbruc
1
360
淘宝旅行门票iPad版开发
ningzbruc
0
160
Travel on KISSY mini
ningzbruc
0
210
Events
ningzbruc
2
130
Other Decks in Technology
See All in Technology
Software Engineering in an AI-Driven World
erikjhordan_rey
0
110
Don't write the architecture only in the prompt.
neohsu
0
310
Flutter Webを「SDK」として配る — 50以上のゲームを支える埋め込みアーキテクチャ
masayukisuda
0
180
Active Directory と Entra ID のむむむな関係
murachiakira
PRO
0
590
Content Mapper APIの応用例~CSS Modules、言語ファイル~
uhyo
2
550
あなたのDartコードは丸見えかもしれない ~reFlutterで暴くFlutterアプリの中身と多層防御~
zozotech
PRO
0
770
AI Search (Foundry IQ) におけるRAGデータの準備と配置
ryomaru0825
1
140
`go get`したらELFが降ってきた件
taiyow
0
160
AI秘書と毎日働くのはもう当たり前。開発以外の業務に足りない機能をどう埋める?
minorun365
PRO
4
2.2k
Autonomous AI Lakehouse - Live AI Hubから始めるセキュアなAIデータ活用 -
oracle4engineer
PRO
3
190
FinOpsを導入してマルチプロダクトのコスト最適化を実現する
kworkdev
PRO
0
120
なぜ東京にいる私が、新潟の技術コミュニティを運営するのか by 八雲慎之助
yakumo
0
220
Featured
See All Featured
Code Review Best Practice
trishagee
74
20k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
570
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
2
1k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
Code Reviewing Like a Champion
maltzj
529
40k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
560
Google's AI Overviews - The New Search
badams
0
1.7k
The Invisible Side of Design
smashingmag
301
52k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
350
Transcript
YUI3 Custom Event System ]{
Pub/Sub
Observer Design Pattern
Subject Observer Notify Attach
YUINode.on('click', function(e) { console.log(e.type); // click });
Subject Observer
MySlider.on('switch', function(e) { // more code here
});
Y.EventTarget
Y.EventTarget Y.CustomEvent Y.Subscriber Y.EventHandle Y.EventFacade
// Step 1 var MyEventTarget = new Y.EventTarget(); //
Step 2 var MyCustomEvent = ET.publish('myevent'); // Step 3 var MySubscriber = function(MyEventFacade) { // Step 6 console.log(MyEventFacade.foo); // 1 }; // Step 4 var MyEventHandle = MyEventTarget.on('myevent', MySubscriber); // Step 5 ET.fire('myevent', { foo: 1, bar: 2 }); // Step 7 MyEventHandle.detach();
publish on fire ... Y.EventTarget _yuievt.events {eventtype: new Y.CustomEvent()}
on fire detach ... Y.CustomEvent subscribers {id: new Y.Subscriber()}
notify ... Y.Subscriber fn context args id
detach batch ... Y.EventHandle evt: Y.CustomEvent sub: Y.Subscriber
preventDefault stopPropagation halt ... Y.EventFacade type target currentTarget details args
...
function MyWidget() { this.name = 'mywidget'; }
Y.augment(MyWidget, Y.EventTarget); // MyWidget.publish(...) // MyWidget.on(...) // MyWidget.fire(...)
Y Y.Global Attribute Base Widget Model ...
function Mod(name) { this.name = name;
this.publish('render', { fireOnce: true }); } Y.augment(Mod, Y.EventTarget); Mod.prototype = { render: function() { // more code this.fire('render', { args: YArray(arguments, 0, true) }); return this; } }; Mod.create = function(name, methods) { return Y.mix(new Mod(name), methods); }
var Mod_A = Mod.create('a', { getModBData: function()
{ Mod_B.on('render', function(e) {...}) } }); var Mod_B = Mod.create('b', methods); Mod_A.render().getModBData(); // more code // lazyload Mod_B.render();
Just Do It!
Y.Do
Y.Do.before(fn, obj, sFn, c, args)
None
The end. ]{