Reactive Programming,
Unity 3D and you
Quick tutorial for using UniRx
by Sam Megidov
ReactiveX is a combination of the best ideas from the Observer pattern, the Iterator pattern, and functional programming.
var score = new ReactiveProperty<Int>(0)
score.SubscribeToText(scoreText)
Now every time score changes,
we update text in the scoreText GameObject.
No need to put that code into an update loop !
score
.Scan(int.MinValue, Mathf.Max)
.SubscribeToText (highscoreText)
var scoreDelayed = score.Throttle(TimeSpan.FromMilliseconds(500))
.ToReactiveProperty()
Accumulates amount of added score with a window of 500ms.
scoreDelayed.SubscribeToText(scoreText)
score.Select(x => x - scoreDelayed.Value)
.SubscribeToText(scoreDeltaText)
Sam Megidov
https://be.linkedin.com/in/sammeg