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
knockout.jsの紹介(オープンセミナー2017@広島)
Search
Makoto Henmi
March 02, 2017
Programming
0
460
knockout.jsの紹介(オープンセミナー2017@広島)
オープンセミナー2017@広島で発表した資料です。
knockout.jsの簡単な紹介です。
Makoto Henmi
March 02, 2017
Tweet
Share
More Decks by Makoto Henmi
See All by Makoto Henmi
ちいさくはじめるBacklog【令和最新版】
makowis
0
110
ちいさくはじめるBacklog
makowis
2
190
Firebase Hostingにシングルページアプリケーションをデプロイしてみよう #gbdaitokai
makowis
1
710
ノベルティのパッケージング
makowis
1
320
スパロボ遍歴
makowis
1
92
昔懐かしいインターネットの風物詩を最近の技術で作る話
makowis
1
3.9k
5分でわかるホワイトボードチャレンジ
makowis
1
470
ぼくらのかんがえたさいきょうのリモート雑談環境 #oso2018
makowis
0
1.8k
朝会をやめた話
makowis
0
5.6k
Other Decks in Programming
See All in Programming
Missing parts when designing and implementing Android UI
ericksli
0
320
RubyLSPのマルチバイト文字対応
notfounds
0
120
.NET Conf 2024の振り返り
tomokusaba
0
110
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
6
1.9k
flutterkaigi_2024.pdf
kyoheig3
0
240
デザインパターンで理解するLLMエージェントの作り方 / How to develop an LLM agent using agentic design patterns
rkaga
9
1.8k
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
230
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
690
EMになってからチームの成果を最大化するために取り組んだこと/ Maximize team performance as EM
nashiusagi
0
110
WebAssembly Unleashed: Powering Server-Side Applications
chrisft25
0
1.5k
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
260
Featured
See All Featured
Fireside Chat
paigeccino
34
3k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Designing the Hi-DPI Web
ddemaree
280
34k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
What's in a price? How to price your products and services
michaelherold
243
12k
Designing Experiences People Love
moore
138
23k
Transcript
knockout.jsͷհ 2017/2/25 Φʔϓϯηϛφʔ2017@ౡ ҳݟ (@mako_wis)
ࣗݾհ w ҳݟ ΜΈ·͜ͱ w 5XJUUFS!NBLP@XJT w גࣜձࣾΫϨΦϑʔΨ w
ϑϩϯταʔόʔαΠυΤϯδχ ΞɾจষνΣοΫ
ࠓԬࢁ͔Βདྷ·ͨ͠
ԬࢁͷίϛϡχςΟ • ԬࢁRubyίϛϡχςΟ • ԬࢁJavaϢʔβʔձ • OITEC(Okayama IT Engineers Community)
• okayama-js • தࠃํσʔλϕʔεษڧձ • ΦʔϓϯηϛφʔԬࢁ • Atlassian User Group தࠃ • ߹ಉษڧձ
knockout.jsͷհ 2017/2/25 Φʔϓϯηϛφʔ2017@ౡ ҳݟ (@mako_wis)
࠷ۙͬͯΔJSपΓͷٕज़ • TypeScript • ੩తܕ͖ݴޠͬΆ͔͚͘Δ • knockout.js • ࠓͷ
JavaScriptͰ ໘͍͘͞ͳͱࢥ͏͜ͱ
ೖྗʹԠͯ͡දࣔΛม͑Δ
ͦͷଞ͕͋ΔϑΥʔϜ
࡞Δͷ໘͍͘͞Ͱ͢ΑͶʁ
knockout.jsͩͱ
ͦͷଞϑΥʔϜ <label> ɹ<input type="radio" name="area" value="okayama" data-bind="checked: radioSelectedValue”/> Ԭࢁࢢ </label>
ɾɾɾ <label> ɹ<input type="radio" name="area" value="other" data-bind="checked: radioSelectedValue”/> ɹͦͷଞ </label> <input type="text" data-bind="enable: selectedOther" placeholder="ͦͷଞͷํ~"/> function viewModel() { var self = this; self.radioSelectedValue = ko.observable("okayama"); self.selectedOther= ko.computed(function() { return self.radioSelectedValue() == "other"; }); }; ko.applyBindings(new viewModel()); KBWB4DSJQU IUNM
ͦͷଞϑΥʔϜ <label> ɹ<input type="radio" name="area" value="okayama" data-bind="checked: radioSelectedValue”/> Ԭࢁࢢ </label>
ɾɾɾ <label> ɹ<input type="radio" name="area" value="other" data-bind="checked: radioSelectedValue”/> ɹͦͷଞ </label> <input type="text" data-bind="enable: selectedOther" placeholder="ͦͷଞͷํ~"/> function viewModel() { var self = this; self.radioSelectedValue = ko.observable("okayama"); self.selectedOther= ko.computed(function() { return self.radioSelectedValue() == "other"; }); }; ko.applyBindings(new viewModel()); KBWB4DSJQU IUNM ϥδΦϘλϯͷબ͕ಉظ
ͦͷଞϑΥʔϜ <label> ɹ<input type="radio" name="area" value="okayama" data-bind="checked: radioSelectedValue”/> Ԭࢁࢢ </label>
ɾɾɾ <label> ɹ<input type="radio" name="area" value="other" data-bind="checked: radioSelectedValue”/> ɹͦͷଞ </label> <input type="text" data-bind="enable: selectedOther" placeholder="ͦͷଞͷํ~"/> function viewModel() { var self = this; self.radioSelectedValue = ko.observable("okayama"); self.selectedOther= ko.computed(function() { return self.radioSelectedValue() == "other"; }); }; ko.applyBindings(new viewModel()); KBWB4DSJQU IUNM ͦͷଞೖྗཝͷ༗ޮແޮ੍ޚ
knockout.js ڵຯ͍͖ͯ·ͨ͠ΑͶʁ
knockout.jsͱ
ओͳಛ ˞ຊޠυΩϡϝϯτ͔ΒҾ༻ w ΤϨΨϯτͳґଘτϥοΩϯά w σʔλϞσϧ͕มߋ͞ΕΔʹɺ6*ͷؔ࿈͚ΒΕͨ෦Λߋ৽͠·͢ɻ w એݴܕόΠϯσΟϯά w σʔλϞσϧͱ6*Λؔ࿈͚ΔɺγϯϓϧͰ໌֬ͳํ๏Ͱ͢ɻෳࡶͳಈత
6*ɺόΠϯσΟϯάɾίϯςΩετΛ֊Խͤ͞Δ͜ͱͰ؆୯ʹ࡞Ͱ ͖·͢ɻ w ֦ு͕༰қ w ৽ͨͳόΠϯσΟϯάͷΈΛ࣮͢Δ͜ͱɺ࠷খݶͷίʔυྔͰ ࣮ݱͰ͖·͢ɻ
ͦͷଞͷϝϦοτ ˞ຊޠυΩϡϝϯτ͔ΒҾ༻ w ७ਮͳ+BWB4DSJQUϥΠϒϥϦͰ͋Δ w αʔόαΠυ ɹΫϥΠΞϯταΠυͷٕज़Λબͼ·ͤ Μɻ w طଘͷ8FCΞϓϦέʔγϣϯʹೖͰ͖Δ
w ΞʔΩςΫνϟʹେ͖ͳมߋΛඞཁͱ͠·ͤΜɻ w ϝΠϯετϦʔϜͷϒϥβΛαϙʔτ w *&Ҏ߱ 'JSFGPYҎ߱ $ISPNF 4BGBSJ
ࠓճͷσϞ https://makowis.github.io/ okayamajs2016/
͏ͱָͰ͖Δॴ
ೖྗΛಉظ͍ͨ͠
ೖྗΛಉظ͢Δ <input type="text" data-bind="value: message” /> <br /> <span data-bind="text:
message”></span> function TestappViewModel() { var self = this; self.message = ko.observable("Hello World!!”); }; ko.applyBindings(new TestappViewModel()); KBWB4DSJQU IUNM ೖྗ͕ಉظ
ΫϦοΫʹରͯ͠Կ͔͍ͨ͠
ΫϦοΫͰΧϯτΞοϓ <span data-bind="text: numberOfClicks”></span> ճΫϦοΫ͠·ͨ͠ <button data-bind="click: incrementClickCounter” > ΫϦοΫ͍ͯͩ͘͠͞
</button> function TestappViewModel() { var self = this; self.numberOfClicks = ko.observable(0); self.incrementClickCounter = function() { var previousCount = self.numberOfClicks(); self.numberOfClicks(previousCount + 1); }; }; ko.applyBindings(new TestappViewModel()); KBWB4DSJQU IUNM ΧϯτΛಉظ
ΫϦοΫͰΧϯτΞοϓ <span data-bind="text: numberOfClicks”></span> ճΫϦοΫ͠·ͨ͠ <button data-bind="click: incrementClickCounter” > ΫϦοΫ͍ͯͩ͘͠͞
</button> function TestappViewModel() { var self = this; self.numberOfClicks = ko.observable(0); self.incrementClickCounter = function() { var previousCount = self.numberOfClicks(); self.numberOfClicks(previousCount + 1); }; }; ko.applyBindings(new TestappViewModel()); KBWB4DSJQU IUNM ΫϦοΫ࣌ͷΠϕϯτ ΧϯτΞοϓॲཧ
ྻʹೖͬͯΔσʔλΛදࣔ
ྻͷσʔλΛग़ྗ <ul data-bind="foreach: users” > <li> <span data-bind="text: name”><span/> <span
data-bind="text: type”><span/> </li> </ul> function TestappViewModel() { var self = this; self.users = ko.observableArray([ { name: "ଠ", type: "உ" }, { name: "ೋ", type: "࣍உ" }, { name: "Ֆࢠ", type: "ঁ" } ]); }; ko.applyBindings(new TestappViewModel()); KBWB4DSJQU IUNM දࣔ༻ͷྻσʔλ
ྻͷσʔλΛग़ྗ <ul data-bind="foreach: users” > <li> <span data-bind="text: name”><span/> <span
data-bind="text: type”><span/> </li> </ul> function TestappViewModel() { var self = this; self.users = ko.observableArray([ { name: "ଠ", type: "உ" }, { name: "ೋ", type: "࣍உ" }, { name: "Ֆࢠ", type: "ঁ" } ]); }; ko.applyBindings(new TestappViewModel()); KBWB4DSJQU IUNM ྻσʔλ<li>λάҎԼΛ ܁Γฦ͠ ܁Γฦ͠෦
ྻͷσʔλΛग़ྗ <ul data-bind="foreach: users” > <li> <span data-bind="text: name”><span/> <span
data-bind="text: type”><span/> </li> </ul> function TestappViewModel() { var self = this; self.users = ko.observableArray([ { name: "ଠ", type: "உ" }, { name: "ೋ", type: "࣍உ" }, { name: "Ֆࢠ", type: "ঁ" } ]); }; ko.applyBindings(new TestappViewModel()); KBWB4DSJQU IUNM ྻͷதͱϚοϐϯά
ৄ͍͠ใ ຊޠυΩϡϝϯτͰ http://kojs.sukobuto.com/
࣮ࡍͬͯΈͯͲ͏ͳͷʁ
ݸਓతʹ͍͍ͳͱࢥͬͯΔॴ w ը໘पΓͷ੍ޚʹಛԽͯ͠Δ w $44ͷ͚ସ͑ɺදࣔΓସָ͕͑ w +BWBTDSJQU༻ͷΫϥεΛ͚ͳ͍͍ͯ͘ w 8FCϑϨʔϜϫʔΫͷྖҬͱ՞͠ͳ͍
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠