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
falcor-with-react
Search
Yosuke Kurami
April 25, 2016
Programming
460
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
falcor-with-react
Yosuke Kurami
April 25, 2016
More Decks by Yosuke Kurami
See All by Yosuke Kurami
TypeScript LSP の今までとこれから
quramy
1
2.1k
フロントエンドテストの育て方
quramy
12
3.8k
App Router 悲喜交々
quramy
8
740
上手に付き合うコンポーネントテスト
quramy
6
2.4k
Patched fetch did not work
quramy
6
790
GraphQL あるいは React における自律的なデータ取得について
quramy
18
5.9k
Next.js App Router
quramy
15
3.9k
Fragment Composition of GraphQL
quramy
17
4.8k
reg-viz VRT tools
quramy
4
1.7k
Other Decks in Programming
See All in Programming
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
630
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
490
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.4k
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
190
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
1.1k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
200
yield再入門 #phpcon
o0h
PRO
0
240
OSINT for SRE: 学術論文とポストモーテムから探る システム障害の共通パターン / SRE NEXT 2026
tomoyk
1
3.6k
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
330
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
170
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
2.5k
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
2
260
Featured
See All Featured
The SEO Collaboration Effect
kristinabergwall1
1
500
Ethics towards AI in product and experience design
skipperchong
2
330
Docker and Python
trallard
47
4k
Paper Plane
katiecoart
PRO
2
52k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
New Earth Scene 8
popppiees
3
2.4k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
760
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.7k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
1k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Transcript
Falcor + React.js @Quramy 2016.04.25
About me • @Quramy (Yosuke Kurami) • Frontend Web Developer
at WACUL INC. • develop SPA with Angular(1 and 2) • झຯͰTypeScript༻ͷVimϓϥΪϯ։ൃͯ͠·͢ • http://vimawesome.com/plugin/tsuquyomi
I ♥ TypeScript falcor.d.ts was merged into Definitely Typed .
Why Falcor ?
SPAͷ՝(RIA, Mobile͖ͬͱҰॹ) • Frontend(UI)ͷཉٻ: • ࠷খݶͷϦΫΤετͰը໘ʹඞཁॆͳ ใ͕ཉ͍͠ • Backend(API)ͷཉٻ: •
Serviceͷઃܭͱ࣮ʹઐ೦͍ͨ͠
ݱ࣮… • ʮը໘ʹ࠷దԽͨ͠APIʹ͢Δͥʂʯ ˠ API endpoint͕ը໘ຖʹͭ͘ΔӋʹ • ʮͲͷը໘͔Β͑ΔAPI࡞ͬͨͥʂʯ ˠ ͦͷը໘Ͱඞཁͱ͠ͳ͍ଐੑΛେྔʹ
ؚΜͩJSON͕ฦ٫͞ΕΔ
Կ͔ղܾࡦແ͍ͷ͔…
ͦ͏ͩʂBFFͩʂ
Backends For Frontends (BFF) The BFF is tightly coupled to
a specific user experience, and will typically be maintained by the same team as the user interface. http://samnewman.io/patterns/architectural/bff/#bff
BFFʹد͍ͤͯΔظ • ServiceυϝΠϯʹ߹ΘͤͯendpointΛެ ։͢ΕΑ͍ • UIͷҰ࣍తͳཁٻBFF͕ड͚͚Δ ݸผServiceͷ͍߹Θͤ݁ՌΛUIʹ࠷దԽ ͯ͠ฦ٫͢Δ
What Falcor does Resources for UI (JSON Graph) Services BFF
! http://netflix.github.io/falcor/starter/what-is-falcor.html#one-model-everywhere
Falcor is one of BFF implementation Sam Newman refers: http://samnewman.io/patterns/architectural/bff/#comment-2386306596
Falcor is Universal Falcor.ModelΛར༻͢Δίʔυ Browser/Node.js྆ํͰಈ͘ ˠ testSSRͰ͑ͦ͏
How to use Falcor with React.js
Async MVC http://netflix.github.io/falcor/starter/what-is-falcor.html#bind-to-the-cloud
Ͳ͔ͬͰݟͨ͜ͱ͋Δͧɻɻ
React + Flux https://github.com/facebook/flux#flux
૬ੑྑͦ͞͏ͳͷͰͬͯΈͨ https://github.com/Quramy/react-falcor-demo#inetgrated-with-flux
Falcor.Model as store import {Model} from 'falcor'; import {Store} from
'../../../lib/built'; /*** Store ***/ export const store = Store.createFromModel(new Model({ cache: { count: 0 } }));
React.Component as View // Component export class App extends React.Component<{count:
number, dispatch: (action: Action<any>) => void}, {}> { render() { const {count} = this.props; const countUp = this.countUp.bind(this); return ( <div> <p>This is simple demonstation of Falcor, React and flux.</p> <button onClick={countUp}>Click + 1</button> <span>{count}</span> </div> ); } countUp() { this.props.dispatch(countUpAction(this.props.count + 1)); } }
Connect them import * as React from 'react'; import {render}
from 'react-dom'; import {connectModel} from '../../../lib/built'; // App Container const AppContainer = connectModel(App, store, { // Component’s property < - > Path of JSON Graph count: 'count' }); /*** Bootstrap ***/ render(<AppContainer dispatch={dispatcher.dispatch.bind(dispatcher)}/>, document.getElementById('app'));
ͬͨ͜ͱ1 • Falcor.ModelͷonChangeΛhookͯ͠ ObservableͳStoreΛ࡞Δ • Store(JSON Graph)ͷมߋΛView subscribe͢ΔΈ
ͬͨ͜ͱ2 • React.ComponentΛड͚ͱͬͯComponentΛฦؔ͢ (=connectModel)Λ࡞ • ReactͷLifecycle hook + StoreͷonChangeʹͯ JSON
Graph͔ΒstateΛੜɺҾComponentͷ props٧ΊࠐΉ • ʮComponent͔ΒContainerΛ࡞Δʯ ˠ ReduxRelayΛࢀߟʹ͍ͯ͠Δ
·ͱΊ • FalcorBFFج൫ͱͯ͑ͦ͠͏ • Store(ͷେ)ΛFalcor.ModelͰӅṭ͢Δ • ContainerؔΛࣗ࡞͢Δ͜ͱͰɺ Falcor(JSON Graph)͔ΒͷऔಘΛએݴతʹ هड़Ͱ͖ͦ͏