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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
990
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
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
240
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
690
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
170
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
560
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
310
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
4k
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
140
Agents on Rails - Rails at Scale 2026
irinanazarova
0
270
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
370
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
380
速習iPhone Duo対応
yuukiw00w
2
840
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
Between Models and Reality
mayunak
4
470
A better future with KSS
kneath
240
18k
Ethics towards AI in product and experience design
skipperchong
2
380
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
450
Code Review Best Practice
trishagee
74
20k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
840
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
The untapped power of vector embeddings
frankvandijk
2
1.9k
The Language of Interfaces
destraynor
162
27k
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