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
Fuck redux! The true story about “Replacing Re...
Search
Jarl André Hübenthal
September 14, 2017
Programming
230
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Fuck redux! The true story about “Replacing Redux with RxJS”
JavaZone 2017 lightning talk
Jarl André Hübenthal
September 14, 2017
More Decks by Jarl André Hübenthal
See All by Jarl André Hübenthal
ReactJS - Replacing Redux with RxJS
jarlah
0
120
Other Decks in Programming
See All in Programming
SalesForceを内製化!? ~ HR事業を支える顧客管理基盤のインフラを大公開 ~
oku053
0
180
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
280
外から家のPCの電源入れたい!をPHPで解決する
kawashimo0
1
140
ActionController meets Protocol Buffers
sorah
0
560
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
260
Performance Optimization With LLMs
xleitix
0
140
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
160
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
700
Web Framework Benchmark Battle 2026, Any%
a_matsuda
2
2.5k
Kotlinの15年とServer-Side Kotlin
n_takehata
1
150
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Featured
See All Featured
A better future with KSS
kneath
240
18k
How to Think Like a Performance Engineer
csswizardry
28
2.9k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
370
Leo the Paperboy
mayatellez
10
2.4k
Writing Fast Ruby
sferik
630
63k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
Building Better People: How to give real-time feedback that sticks.
wjessup
371
20k
4 Signs Your Business is Dying
shpigford
187
23k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
520
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
270
Transcript
Fuck redux! The true story about “Replacing Redux with RxJS”
JavaZone 2017
About us! Ingar Abrahamsen @ingarabr Jarl André Hübenthal @jarlandreh
What we had to work with React / redux /
redux middlewares / websockets / server side render / <insert npm package x, y and z>
Reactive streams RxJS
Our new hipster stack! Flow / React / RxJS /
Lodash
None
Show us some code! Counter example https://github.com/jarlah/react-rxjs-example/tree/v0.1
// @flow import React from 'react'; export type Props =
{ state: number, increase: (n: number) => mixed , decrease: (n: number) => mixed }; export function CounterPage(props: Props) { return ( <div className="container"> <h1>Counter</h1> <p>{props.state}</p> <button onClick={() => props.increase(1)}>+</button> <button onClick={() => props.decrease(1)}>-</button> </div> ); }
// @flow import { Observable, Subject } from 'rxjs'; import
{ createStore } from 'react-rxjs/dist/RxStore' ; type Number = { n: number }; export const increase$: Subject<Number> = new Subject(); export const decrease$: Subject<Number> = new Subject(); const reducer$ = (actions: *) => Observable. merge( actions.increase$.map(number => state => state + number.n) , actions.decrease$.map(number => state => state - number.n) ); export const store = (actions: *) => createStore('counter', reducer$(actions), 0); export default store({ increase$, decrease$ });
// @flow import store$, { decrease$, increase$ } from './store';
import inject from 'react-rxjs/dist/RxInject' ; import { CounterPage } from './view'; function props(state) { return { state, increase: n => increase$.next({ n }) , decrease: n => decrease$.next({ n }) }; } export default inject(store$, props)(CounterPage);
// @flow import { store } from '../store'; import {
TestScheduler } from 'rxjs/Rx'; describe('counter store', () => { it('increase and decrease', () => { const ts = new TestScheduler((a, b) => expect(a).toEqual(b)); const streams = { inc: '-ab--', dec: '---ab', res: 'abcde' }; const n = { n: 1 }; const increase$ = ts.createHotObservable(streams.inc, { a: n, b: n}); const decrease$ = ts.createHotObservable(streams.dec, { a: n, b: n}); const resultMap = { a: 0, // init b: 1, c: 2, // inc d: 1, e: 0 // dec }; ts.expectObservable(store({ increase$, decrease$ })).toBe(streams.res, resultMap); ts.flush(); }); });
Conclusion Keep it simple, stupid (KISS) Single responsibility principle