Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/rx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@veritas-vos-liberabit.com>2013-03-28 00:53:22 +0400
committerAtsushi Eno <atsushieno@veritas-vos-liberabit.com>2013-03-28 00:53:22 +0400
commit051415e5fb90a038afe3681aa087cfa28965074e (patch)
tree64682b8df5439afb61b3534fb731b49ba61d9c5e
parent43326ab0cbac16bb0c9f745be469ad0e429e3bad (diff)
add GettingStarted.md and misc packaging updates.
-rw-r--r--xpkg/GettingStarted.md108
-rw-r--r--xpkg/README3
-rw-r--r--xpkg/ReactiveExtensionsForXamarin_128x128.png (renamed from xpkg/logo_128x128.png)bin12929 -> 12929 bytes
-rwxr-xr-xxpkg/build-package.sh30
4 files changed, 128 insertions, 13 deletions
diff --git a/xpkg/GettingStarted.md b/xpkg/GettingStarted.md
new file mode 100644
index 0000000..a15d666
--- /dev/null
+++ b/xpkg/GettingStarted.md
@@ -0,0 +1,108 @@
+This Reactive Extensions (Rx) component is to package Reactive Extensions (version 2.x) from Microsoft.
+
+Rx is published as an open source project and you can pick up sources from CodePlex (http://rx.codeplex.com). There is a dedicated web page section for Rx on MSDN website too: http://msdn.microsoft.com/en-us/data/gg577609.aspx
+
+This component contains Rx libraries that are suited for Xamarin.Android and Xamarin.iOS.
+
+We are not going to explain what is Rx and how the library works. To begin with basics of Rx, their website has lots of introductory materials on those websites. On this document, we explain how to use Rx in Xamarin products.
+
+# Adjusting Library References
+
+After adding this component to your project, you would notice that there are several dlls in this package. You would however most likely need to use the following four assemblies:
+
+* System.Reactive.Interfaces.dll
+* System.Reactive.Core.dll
+* System.Reactive.Linq.dll
+* System.Reactive.PlatformServices.dll
+
+All other assemblies are optional and you would like to use them only in certain scenarios. On the other hand, those four assemblies are essential. So far let's remove other assemblies in this package.
+
+<img src="ProjectReferences.png" />
+
+(Note that Rx version 2.x is very different from Rx v1.0 in terms of assemblies; Rx 1.0 consists only of System.Reactive.dll, which does not exist in Rx v2.x.)
+
+# Sample: Transforming touch events into another event
+
+Here I show an example use of Observable.FromEventPattern() and Observable.ToEventPattern() methods to turn View.Touch event into "notify only when three fingers are moving" event (here I named it as "TripleTouch").
+
+Let's begin with a simple application project. After you created one, you will need some using statements for Rx:
+
+ using System.Reactive;
+ using System.Reactive.Linq;
+
+The "TripleTouch" event is defined and implemented as follows:
+
+ IEventPatternSource<View.TouchEventArgs> triple_touch_source;
+
+ public event EventHandler<View.TouchEventArgs> TripleTouch {
+ add { triple_touch_source.OnNext += value; }
+ remove { triple_touch_source.OnNext -= value; }
+ }
+
+This event is populated when the View is set up. In the simple application sample, I wrote this in the Activity's OnCreate():
+
+ ...
+ // this "surface" is the target View here.
+ // It can be "this" when you implement a custom component.
+ var surface = FindViewById<View> (Resource.Id.theToucheable);
+
+ triple_touch_source = Observable.FromEventPattern<View.TouchEventArgs> (surface, "Touch")
+ .Where (ev => ev.EventArgs.Event.Action == MotionEventActions.Move)
+ .Where (ev => ev.EventArgs.Event.PointerCount == 3)
+ .ToEventPattern ();
+ ...
+
+Then it could be consumed by the View users (in the sample, the first line of code is in OnCreate() method):
+
+ ...
+ TripleTouch += (sender, ev) => this.RunOnUiThread (() => text.Text = GetEventDescription (ev.Event));
+ ...
+
+ static string GetEventDescription (MotionEvent e)
+ {
+ return string.Format ("({0}, {1})", e.RawX, e.RawY);
+ }
+
+In the sample app project, we defined very simple UI in Main.axml:
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+ <View
+ android:id="@+id/theToucheable"
+ android:layout_width="fill_parent"
+ android:layout_height="440.7dp"
+ android:layout_marginBottom="0.0dp" />
+ <TextView
+ android:id="@+id/theText"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="(touch corrdinates shown here)" />
+ </LinearLayout>
+
+The sample is all done. Build and run the app on device. Then touch one finger. Nothing happens. Touch with one more finger. Still nothing happens. Add another finger. Then it starts showing the coordinate (of the first finger; this is just a sample so it doesn't give complicated action).
+
+What implements such behavior? Let's see the Observable part:
+
+ triple_touch_source = Observable.FromEventPattern<View.TouchEventArgs> (surface, "Touch")
+
+This converts View.Touch event into an IObservable.
+
+ .Where (ev => ev.EventArgs.Event.Action == MotionEventActions.Move)
+
+This filters out events that are not move events.
+
+ .Where (ev => ev.EventArgs.Event.PointerCount == 3)
+
+This filters out events that don't detect three fingers. Now that we have only three-fingered events, we want to convert this observables into another event source:
+
+ .ToEventPattern ();
+
+Once it's done, we use it to process the actual event. Note that since we are going to control UI, we need to invoke RunOnUiThread():
+
+ TripleTouch += (sender, ev) => this.RunOnUiThread (() => text.Text = GetEventDescription (ev.Event));
+
+Actually, if you don't convert the filtered observables into another event, you might want to use SynchronizationContext instead (we didn't do that in this example because having event processing all within the UI thread is not good):
+
+ (...) .SubscribeOn (Android.App.Application.SynchronizationContext) (...)
diff --git a/xpkg/README b/xpkg/README
index 229e3ab..8a9f7ff 100644
--- a/xpkg/README
+++ b/xpkg/README
@@ -1,7 +1,6 @@
run:
- ln -s path/to/mono/mcs mcs
- ln -s path/to/mono/external external
+ ln -s ../Rx/NET/Source/Rx_Xamarin Rx_Xamarin
./build-package.sh
diff --git a/xpkg/logo_128x128.png b/xpkg/ReactiveExtensionsForXamarin_128x128.png
index 9da8fee..9da8fee 100644
--- a/xpkg/logo_128x128.png
+++ b/xpkg/ReactiveExtensionsForXamarin_128x128.png
Binary files differ
diff --git a/xpkg/build-package.sh b/xpkg/build-package.sh
index eb6cc63..e9d689c 100755
--- a/xpkg/build-package.sh
+++ b/xpkg/build-package.sh
@@ -1,19 +1,27 @@
#!/bin/sh
-mono xpkg.exe create ReactiveExtensionsForXamarin-1.0.xam \
+mono xpkg.exe create ReactiveExtensionsForXamarin-2.1.xam \
--name="Reactive Extensions for Android" \
--publisher="Xamarin, Inc." \
--website="http://www.xamarin.com" \
--summary="a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators." \
- --license="external/rx/Rx/NET/Source/license.txt" \
- --library=android:external/rx/Rx/NET/Source/Rx_Xamarin/android/libs/System.Reactive.Interfaces.dll \
- --library=android:external/rx/Rx/NET/Source/Rx_Xamarin/android/libs/System.Reactive.Core.dll \
- --library=android:external/rx/Rx/NET/Source/Rx_Xamarin/android/libs/System.Reactive.Linq.dll \
- --library=android:external/rx/Rx/NET/Source/Rx_Xamarin/android/libs/System.Reactive.PlatformServices.dll \
- --library=android:external/rx/Rx/NET/Source/Rx_Xamarin/android/libs/System.Reactive.Experimental.dll \
- --library=android:external/rx/Rx/NET/Source/Rx_Xamarin/android/libs/System.Reactive.Debugger.dll \
- --library=android:external/rx/Rx/NET/Source/Rx_Xamarin/android/libs/System.Reactive.Providers.dll \
+ --license="../Rx/NET/Source/license.txt" \
+ --library=android:Rx_Xamarin/android/libs/System.Reactive.Interfaces.dll \
+ --library=android:Rx_Xamarin/android/libs/System.Reactive.Core.dll \
+ --library=android:Rx_Xamarin/android/libs/System.Reactive.Linq.dll \
+ --library=android:Rx_Xamarin/android/libs/System.Reactive.PlatformServices.dll \
+ --library=android:Rx_Xamarin/android/libs/System.Reactive.Experimental.dll \
+ --library=android:Rx_Xamarin/android/libs/System.Reactive.Debugger.dll \
+ --library=android:Rx_Xamarin/android/libs/System.Reactive.Providers.dll \
+ --library=iOS:Rx_Xamarin/iOS/libs/System.Reactive.Interfaces.dll \
+ --library=iOS:Rx_Xamarin/iOS/libs/System.Reactive.Core.dll \
+ --library=iOS:Rx_Xamarin/iOS/libs/System.Reactive.Linq.dll \
+ --library=iOS:Rx_Xamarin/iOS/libs/System.Reactive.PlatformServices.dll \
+ --library=iOS:Rx_Xamarin/iOS/libs/System.Reactive.Experimental.dll \
+ --library=iOS:Rx_Xamarin/iOS/libs/System.Reactive.Debugger.dll \
--details=Details.md \
+ --getting-started=GettingStarted.md \
--getting-started=Details.md \
- --icon=logo_128x128.png \
- --sample="GitHub API Client Sample. GitHub API client sample demonstrates use of Rx API with GitHub:external/rx/Rx/NET/Source/Rx_Xamarin/android/samples/GithubApiClientSample/GithubApiClientSample.sln"
+ --icon=ReactiveExtensionsForXamarin_128x128.png \
+ --sample="Touch Event Observable Sample. Observable event pattern conversion sample using View.Touch event:Rx_Xamarin/android/samples/ReactiveAndroidSample/ReactiveAndroidSample.sln" \
+ --sample="GitHub API Client Sample. GitHub API client sample demonstrates use of Rx API with GitHub:Rx_Xamarin/android/samples/GithubApiClientSample/GithubApiClientSample.sln"