Skip to content

Instantly share code, notes, and snippets.

@arturaz
Created March 24, 2014 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arturaz/9735581 to your computer and use it in GitHub Desktop.
Save arturaz/9735581 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using com.tinylabproductions.TLPLib.Reactive;
using System;
public class CubeComponent : MonoBehaviour, IObserver<string>
{
// Use this for initialization
void Start() {
var tCfg = new GoTweenConfig();
var obs = new Observable<AbstractGoTween>(obs => tCfg.setOnCompleteHandler(obs.push));
Observable.fromEvent(new GoTweenConfig().onComplete);
var t = Observable.a<GoTween, AbstractGoTween>(obs =>
Go.to(null, 0, new GoTweenConfig().onComplete())
);
var strObs = new Observable<string>(obs => obs.push("foo"));
//*****************************
// RXLIST - Compiles, but not sure what do to with this...
//*****************************
var r = new RxList<string> {"hi", "foo", "blah"};
var rv = RxListView.a(r, 0, 10);
rv.startIndex += rv.windowSize;
//*****************************
// OBSERVAB LE - Compiles, but not sure what do to with this...
//*****************************...
Observable.everyFrame().map(_ => Input.mousePosition);
//*****************************
// OBSERVABLE - Compiles, but not sure what do to with this...
//*****************************
Observable.interval(this, 10).filter(dt => dt.Hour == 3).subscribe().unsubscribe()
//*****************************
// SUBSCRIPTION - Compiles, but not sure what do to with this...
//*****************************
Subscription s = new Subscription(onUnsubscribe);
s.unsubscribe();
//*****************************
// OBSERVER - THIS SIMPLE EXAMPLE WORKS GREAT. NOT SURE HOW TO CONNECT THIS OBSERVER TO AN ACTUAL OBSERVABLE THOUGH
//*****************************
Observer<string> observer = new Observer<string>(
unit =>
{
Debug.Log("unit: " + unit);
}
);
observer.push("blah1");
observer.push("blah2");
observer.push("blah3");
}
void onUnsubscribe()
{
Debug.Log("onUnsubscribe()");
}
public void push(string s)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment