This repository has been archived by the owner on Jun 19, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Moving to pull request from email thread:
I started with the iOS implementation, as I wanted to get something up and running to flesh out the API before moving to the other platforms. You can find it here:
https://github.com/joelmartinez/Xamarin.Mobile/tree/master/MonoTouch/Xamarin.Mobile/Motion
I thought it would be interesting to expose an IObservable, so you can use Rx style event handling:
var accelerometer = new MotionManager ();
accelerometer.Subscribe(v => DoSomething (v.X, v.Y, v.Z));
Was considering adding a plain old event as well in case the user doesn’t want to use Rx, or isn’t familiar with it. Also, I’m starting the event polling as soon as you instantiate the class … will probably make it the user’s choice by moving that to a start/stop motif.
Anyways, would love to hear your thoughts on what this simple API looks like, what you’d like to see in it … and also, maybe a bit of history (in case someone already tried to add this before and had difficulties). I’m gonna start testing it more in earnest as soon as I get a better handle on the ideal API and features, and then move to implement the other platforms.
@ermau responded:
I can also tell you that I'm opposed to basing on IObservable. I realize that it's a better solution from an architecture standpoint, but when I wrote the geolocator originally I had the same idea.. turns out its near impossible to sanely consume it without getting Rx, and I do not want to force people into that.
I responded:
Yeah I can fully understand what you’re referring to; I chafed a bit at having to implement my own IObservable since I wasn’t going to make Rx a dependency.