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
120
ちいさくはじめるBacklog
makowis
2
220
Firebase Hostingにシングルページアプリケーションをデプロイしてみよう #gbdaitokai
makowis
1
730
ノベルティのパッケージング
makowis
1
330
スパロボ遍歴
makowis
1
92
昔懐かしいインターネットの風物詩を最近の技術で作る話
makowis
1
3.9k
5分でわかるホワイトボードチャレンジ
makowis
1
490
ぼくらのかんがえたさいきょうのリモート雑談環境 #oso2018
makowis
0
1.8k
朝会をやめた話
makowis
0
5.6k
Other Decks in Programming
See All in Programming
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
320
CloudflareStack でRAGに入門
asahiiwm
0
140
Recoilを剥がしている話
kirik
5
8.1k
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
590
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
320
shadcn/uiを使ってReactでの開発を加速させよう!
lef237
0
210
Findy Team+ Awardを受賞したかった!ベストプラクティス応募内容をふりかえり、開発生産性向上もふりかえる / Findy Team Plus Award BestPractice and DPE Retrospective 2024
honyanya
0
120
ISUCON14感想戦で85万点まで頑張ってみた
ponyo877
0
130
Go の GC の不得意な部分を克服したい
taiyow
3
960
技術的負債と向き合うカイゼン活動を1年続けて分かった "持続可能" なプロダクト開発
yuichiro_serita
0
240
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
9
2.3k
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
380
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
171
50k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Side Projects
sachag
452
42k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
1
150
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.1k
BBQ
matthewcrist
85
9.4k
Measuring & Analyzing Core Web Vitals
bluesmoon
5
190
Fireside Chat
paigeccino
34
3.1k
How STYLIGHT went responsive
nonsquared
96
5.3k
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ϑϨʔϜϫʔΫͷྖҬͱ՞͠ͳ͍
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠