(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Note: if you want to skip history behind this, and just looking for final result see: rx-react-container
When I just started using RxJS with React, I was subscribing to observables in componentDidMount
and disposing subscriptions at componentWillUnmount
.
But, soon I realised that it is not fun to do all that subscriptions(that are just updating property in component state) manually, and written mixin for this...
Later I have rewritten it as "high order component" and added possibility to pass also obsarvers that will receive events from component.
// ------------ | |
// counterStore.js | |
// ------------ | |
import { | |
INCREMENT_COUNTER, | |
DECREMENT_COUNTER | |
} from '../constants/ActionTypes'; | |
const initialState = { counter: 0 }; |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft
, elem.offsetTop
, elem.offsetWidth
, elem.offsetHeight
, elem.offsetParent
VP.init({...})
์ผ๋ก ์ด๊ธฐํ๋ฅผ ํ ๋ ๋ฃ๋ noAd, adDisplayed, hideIframeDuringLoad ๋ชจ๋ ์ญ์ ๋์ด ๋ ์ด์ ์ฌ์ฉ์ด ๋ถ๊ฐ๋ฅํฉ๋๋ค. ๋์ ์ VP.ad(...) ํจ์์ opts ๋ฅผ ํตํด ์ฌ์ฉํ์ธ์.์ด ๊ธ์ ์ฐ๋ฆฌ๊ฐ ์ด ์ฑ , 'Reactive Programming with RxJava' ์ ๋ถ๋ก์ด์๋ค. Reactive programming๊ณผ ๊ด๋ จ์ด ๊น์ ์ฃผ์ ๊ธด ํ์ง๋ง ๋ชจ๋๋๋ฅผ ์๊ฐํ๋ค๋ ๊ฒ ์ฑ ๊ณผ ์ฉ ์ด์ธ๋ฆฌ์ง๋ ์์๋ค. ๊ทธ๋์ ๋๋ ๋ฐ๋ก ๋ธ๋ก๊ทธ์ ์ฌ๋ฆฌ๊ธฐ๋ก ํ๋ค. ํ๋ก๊ทธ๋๋ฐ์ ๋ค๋ฃจ๋ ๋ธ๋ก๊ทธ์์ *"๋ฐ์ ๋ง๊ณ ๋ฐ์ ํ๋ฆด ์ง ๋ชจ๋ฅด๋ ๋๋ง์ ๋ชจ๋๋ ์ค๋ช "*์ด๋ ๊ฒ์ด ์๋ก์ด *"Hello World"*๋ผ๋ ์ ์ ๋๋ ์ ์๋ค. ํ์ง๋ง ์ด ๊ธ์ ํํฐ(functor)์ ๋ชจ๋๋(monad)๋ฅผ ์๋ฐ ์๋ฃ ๊ตฌ์กฐ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ผ๋ ๊ฐ๋์์ ๋ฐ๋ผ๋ณด๊ณ ์์ผ๋ฉฐ, ์ด๋ ๊ณต์ ํ ์ ๋์ ๊ฐ์น๋ ์์๊ฑฐ๋ผ ์๊ฐํ๋ค.
I heard some points of criticism to how React deals with reactivity and it's focus on "purity". It's interesting because there are really two approaches evolving. There's a mutable + change tracking approach and there's an immutability + referential equality testing approach. It's difficult to mix and match them when you build new features on top. So that's why React has been pushing a bit harder on immutability lately to be able to build on top of it. Both have various tradeoffs but others are doing good research in other areas, so we've decided to focus on this direction and see where it leads us.
I did want to address a few points that I didn't see get enough consideration around the tradeoffs. So here's a small brain dump.
"Compiled output results in smaller apps" - E.g. Svelte apps start smaller but the compiler output is 3-4x larger per component than the equivalent VDOM approach. This is mostly due to the code that is usually shared in the VDOM "VM" needs to be inlined into each component. The tr