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
Function API You will use in future
Search
jiko21
July 24, 2019
Programming
1.7k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Function API You will use in future
V-kansai#8の登壇資料です。
jiko21
July 24, 2019
More Decks by jiko21
See All by jiko21
型情報を手繰り寄せる技術~TypeScript Compiler APIによる型解析実践~
jiko21
0
1.2k
Creating a Next.js-style Framework with Bun and Hono
jiko21
0
190
Array Grouping will soon be arriving at TypeScript
jiko21
0
180
Copying Array Methods arrived at TypeScript
jiko21
1
980
SSRで動的に OGP画像を生成したい! 〜Cloudflare Workersから@vercel/og移行編〜
jiko21
0
170
node:test will replace Jest?
jiko21
0
120
どこでも動かすために… TypeScriptでライブラリ開発の すゝめ
jiko21
2
470
NestJS a progressive web framework
jiko21
3
2.3k
レガシーなフロントエンドをリプレイスする
jiko21
5
1.6k
Other Decks in Programming
See All in Programming
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
240
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
1
380
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
1
7.9k
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
230
JRuby: Past, Present, and Future
headius
0
180
XP祭りでしか伝わらないフリップネタ #xpjug
murabayashi
0
150
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
490
wkhtmltopdfの次どうするか問題2026
willnet
2
1.6k
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
120
setup-vp GitLab対応の裏側
naokihaba
0
120
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
340
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
300
Featured
See All Featured
Building Applications with DynamoDB
mza
96
7.2k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
The untapped power of vector embeddings
frankvandijk
2
1.9k
Evolving SEO for Evolving Search Engines
ryanjones
0
300
HDC tutorial
michielstock
2
880
Amusing Abliteration
ianozsvald
1
310
The Curious Case for Waylosing
cassininazir
1
520
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
280
How to train your dragon (web standard)
notwaldorf
97
6.8k
Automating Front-end Workflow
addyosmani
1369
210k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
320
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
910
Transcript
Function API You will use in future v-kansai Vue.js/Nuxt.js meetup
#8 @Daikids2
খౡ େج / Daiki Kojima @Daikids2 @daikikojima ژେֶେֶӃใֶݚڀՊM2 Server/Front, Mobile(iOS/Android)…
Vue fes JPࢀՃ͠·͢!! ࠷ۙFlutterָ͕͍͠…
Posted on … IUUQTTQFBLFSEFDLDPNEBJLJETGVODUJPOBQJZPVXJMMVTFJOGVUVSF
Today’s Topic • Vue 3? • Function API
Vue 3?
Vue 3͕ࠓதʹͰΔͬΆ͍ https://vuefes.jp/2019/
None
RFCʹ͓͚Δݱঢ় ௨ͬͨͷ ৹ٞத ٫Լ (MPCBM"1* 5SFFTIBLJOH 'VODUJPO"1* 7NPEFM"1* $IBOHF
$VTUPN%JSFDUJWF "1*$IBOHF FUDʜ $MBTT4UZMFBQJ ※ࣈഁյతมߋ
ͪͳΈʹ…
Global API TreeShaking • Vue.<͍͍ͨmodule>͡Όͳͯ͘ɺ named exportΛͬͯapiΛར༻͢Δ͜ͱʹ… • Named exportͳͷͰ
Webpackʹ͓͍ͯෆཁͳίʔυ(σουίʔυ) ͷBundleԽΛ͛Δ!!
What’s Function API?
Function API? • Vue 3ʹͯొ(༧ఆ)ͷAPI • ࠓͪΐ͏ͲRFCͰٞத • ͜ΕࣗମVue 2Ͱ
(ϞδϡʔϧͷಋೖͰ) ར༻Մೳ • ࠓ·Ͱͱॻ͖ํ͕ҧ͏? →ݟ͍͖ͯ·͠ΐ͏!!
• Πϯετʔϧͪ͜Β • main.jsʹͯ ͜ͷΑ͏ʹ install ಋೖ $ npm install
vue-function-api --save import Vue from "vue"; import App from "./App.vue"; import store from "./store"; import "./registerServiceWorker"; import { plugin } from 'vue-function-api' Vue.use(plugin)
؆୯ͳαϯϓϧ
ެࣜͷαϯϓϧΛݟͯΈΔ <template> <div class="count"> <span>count is {{ count }}</span> <span>plusOne
is {{ plusOne }}</span> <button @click="increment">count++</button> </div> </template> IUUQTHJUIVCDPNWVFKTWVFGVODUJPOBQJ
ެࣜͷαϯϓϧΛݟͯΈΔ <script> import { value, computed, watch, onMounted } from
'vue-function-api'; export default { setup() { // State const count = value(0); // computed state const plusOne = computed(() => count.value + 1); // Method const increment = () => { count.value++; }; // watch watch( () => count.value * 2, val => { console.log(`cont * 2 is ${val}`); }, ); onMounted(() => { console.log("mounted"); }); return { count, plusOne, increment }; }, }; </script>
جຊ • ObjectΛ࡞Δ • Objectʹؔsetup()Λఆٛͯ͠ɺ ͦͷதʹॲཧΛॻ͍͍ͯ͘ export default { setup()
{ return {}; }, };
Dataͷ࡞ • valueΛ͏! • Ҿ͕ॳظʹͳͬͯ͘ΕΔΑ!! // State const count =
value(0);
DataͷΞΫηε • ม໊.valueͰdataͷʹΞΫηεͰ͖Δ!! count.value++;
Computed state • ࠓ·Ͱcomputedʹॻ͍͍ͯͨͷɺ computedؔΛ༻͍Δ… const plusOne = computed(() =>
count.value + 1);
Method • ΞϩʔؔΛͬͯఆٛ͢Δ͚ͩ!! // Method const increment = () =>
{ count.value++; };
Watch • ࠓ·ͰͷWatchͱগ͠ॻ͖ํ͕มΘͬͯΔ… // watch watch( // getter () =>
count.value * 2, // callback val => { console.log(`cont * 2 is ${val}`); }, ); ࢹ͢ΔΛؔͰฦ͢ ͕มߋ͞ΕͨΒݺͼग़͢
ྫ͑… • ͜ͷΑ͏ͳ߹callback͕ݺΕͳ͍ // watch watch( // getter () =>
count.value * 0, // callback val => { console.log(`cont * 2 is ${val}`); }, ); ৗʹ HFUUFSͷ͕มΘΒݺͼग़͞Εͳ͍
ϥΠϑαΠΫϧؔ • vue-function-apiʹઐ༻ͷ͕ؔ༻ҙ͞Ε͍ͯ·͢… • onXXXXͱ͔ • ҾʹؔΛೖΕͯΕOK onMounted(() => {
console.log("mounted"); });
࠷ޙʹ • statemethodͳͲɺએݴͨ͠ͷΛreturnͰฦ͢ return { count, plusOne, increment };
None
Propsͱ͔Ͳͳ͍͢Δͷ?
࣮… • setupʹҾͱͯ͠propsΛه͢ΕOK • https://github.com/daikikojima/vue-function-api- memo ʹͯpropsΛͬͨ ϝϞΞϓϦΛஔ͍ͯ·͢ɻ export default
{ props: ['addTodo'], setup(props) { const text = value(''); const onAddClick = () => { if (text.value !== '') { props.addTodo(text.value); text.value = ''; } };
৮ͬͯΈͯͷॴײ • ReactͬΆ͍… • ࣮ࡍʹRFCͰʹͳͬͨΓԌ্?ͯͨ͠ • TSͱ૬ੑ͕ྑͦ͞͏…
࠷ޙʹ • ͜͜ͰҰ෦͔͠հ͓ͯ͠Γ·ͤΜɻ ΑΓৄ͍͠ใ https://github.com/vuejs/vue-function-api ʹࡌͬͯ·͢ɻ
Reference? • Vue-function-api https://github.com/vuejs/vue-function-api • Vue rfc (function apiͷproposal) https://github.com/vuejs/rfcs/pull/42
• αϯϓϧͷίʔυ https://github.com/daikikojima/vue-function-api-memo