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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yosuke Kurami
April 25, 2016
Programming
450
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
2k
フロントエンドテストの育て方
quramy
12
3.8k
App Router 悲喜交々
quramy
8
730
上手に付き合うコンポーネントテスト
quramy
6
2.3k
Patched fetch did not work
quramy
6
780
GraphQL あるいは React における自律的なデータ取得について
quramy
18
5.8k
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
3Dシーンの圧縮
fadis
1
690
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
350
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
20
6.5k
Lessons from Spec-Driven Development
simas
PRO
0
170
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
560
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
170
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
520
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
2
690
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
110
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
1.2k
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
4.9k
AutonomyとControlのあいだ:Graflowで記述するAIエージェント協調
myui
0
120
Featured
See All Featured
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.3k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
380
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Prompt Engineering for Job Search
mfonobong
0
340
It's Worth the Effort
3n
188
29k
Odyssey Design
rkendrick25
PRO
2
690
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
330
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
Automating Front-end Workflow
addyosmani
1370
210k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Deep Space Network (abreviated)
tonyrice
0
170
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)͔ΒͷऔಘΛએݴతʹ هड़Ͱ͖ͦ͏