Skip to content

Observable Examples

rpgwhitelock edited this page Jan 8, 2015 · 11 revisions

Snippets, references, samples of UniRX Observables usage in uFrame.

Inspired by http://rxwiki.wikidot.com/101samples


Once per second, execute command to damage player


Observable.Interval(TimeSpan.FromMilliseconds(1000))
	.Subscribe(_ => {
			ExecutedamagePerSecondTick(); 
	}).DisposeWhenChanged(Player.healthStateProperty);


uGUI events as observables. A button as an event stream in your view.



Button poorButton;  // Our button.
 
poorButton.AsClickObservable()
	.Where(_ => YOUR FILTER )
	.Throttle(_ => PREVENT SPAMMING )
	.DelayFrame( FRAMES TO DELAY )
	.SkipWhile( SKIP FIRST TAPS IF CONDITION IS NOT MET )
	.Subscribe(_ =>
	{
		USE LIKE SIMPLE OBSERVABLE
	});

Clone this wiki locally