Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
YUI3 EventTarget
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
ningzbruc
January 24, 2013
Technology
1
64
YUI3 EventTarget
This presentation shows how YUI3 Custom Event System works!
ningzbruc
January 24, 2013
Tweet
Share
More Decks by ningzbruc
See All by ningzbruc
如何写出一个优秀的开源库
ningzbruc
0
59
去啊无线前端的一天
ningzbruc
1
170
React & Component
ningzbruc
0
42
阿里旅行去啊H5首页总结&Promise
ningzbruc
0
260
KISSY.Base - all about that Base
ningzbruc
0
120
Hammer.js
ningzbruc
1
340
淘宝旅行门票iPad版开发
ningzbruc
0
130
Travel on KISSY mini
ningzbruc
0
200
Events
ningzbruc
2
130
Other Decks in Technology
See All in Technology
エンジニアとして長く走るために気づいた2つのこと_大賀愛一郎
nanaism
1
260
Azure SRE Agent x PagerDutyによる近未来インシデント対応への期待 / The Future of Incident Response: Azure SRE Agent x PagerDuty
aeonpeople
0
230
日本語テキストと音楽の対照学習の技術とその応用
lycorptech_jp
PRO
1
350
AI開発をスケールさせるデータ中心の仕組みづくり
kzykmyzw
0
180
Claude Codeベストプラクティスまとめ
minorun365
50
29k
ReproでのicebergのStreaming Writeの検証と実運用にむけた取り組み
joker1007
0
510
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
3.8k
VRTと真面目に向き合う
hiragram
1
500
オープンウェイトのLLMリランカーを契約書で評価する / searchtechjp
sansan_randd
3
350
新規事業における「一部だけどコア」な AI精度改善の優先順位づけ
zerebom
0
400
Amazon Bedrock AgentCore EvaluationsでAIエージェントを評価してみよう!
yuu551
0
180
Riverpod3.xで実現する実践的UI実装
fumiyasac0921
2
340
Featured
See All Featured
Statistics for Hackers
jakevdp
799
230k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
55
49k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Technical Leadership for Architectural Decision Making
baasie
1
220
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
66
36k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
130
So, you think you're a good person
axbom
PRO
2
1.9k
Why Our Code Smells
bkeepers
PRO
340
58k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
260
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
420
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. ]{