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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
220
Webの地図
yosuke_furukawa
PRO
6
4.8k
AI活用は、個人から組織へ|マルチプレイヤーエージェントハーネス「QM」の社内活用事例 / AI use is moving from individuals to orgs
rkaga
1
270
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
250
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.4k
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
540
個人開発基盤をまるごとCloudflareに引っ越して爆速で総合的体験を向上させた話
tinykitten
0
210
AWSに止められる覚悟してますか?
morizo_1984
2
430
MCP Appsでつくるチャット駆動な地図アプリ
nakamori1024
0
110
Heart of Swift Concurrency
koher
0
1k
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
270
Are APIs Still Relevant in the AI Era?
soyuka
0
330
Featured
See All Featured
Become a Pro
speakerdeck
PRO
31
6.3k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
510
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
460
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
340
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
520
The Spectacular Lies of Maps
axbom
PRO
1
1k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
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