Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Accelerometer Support #25

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Accelerometer Support #25

wants to merge 4 commits into from

Conversation

joelmartinez
Copy link
Member

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.

@joelmartinez
Copy link
Member Author

@ermau Do you think the IObservable should be removed entirely to keep it simple, or would it be enough to simply include a regular event member ... that way, those that want to interact via Rx can do so, and those who aren't familiar with it can just attach an event handler and be on their way?

@ermau
Copy link
Member

ermau commented Jan 13, 2014

@joelmartinez Doesn't Rx have an easy event -> observable conversion?

@chamons
Copy link

chamons commented Jan 14, 2014

RX has this: http://rxwiki.wikidot.com/101samples#toc6 which lets you go from bog standard events to their hotness. It is a bit of a mouthful.

@ermau
Copy link
Member

ermau commented Jan 16, 2014

I think that's simple enough that we should go ahead and drop the interface and keep it purely an event. We can always add the direct observable support back later (and add it to geolocator in the process).

@ermau
Copy link
Member

ermau commented Jan 16, 2014

Isn't gyroscope information usually combined with the accelerator to get a more full picture? We should consider what other APIs in this area might look like and if we might want a fuller picture before we drop this in as well.

@joelmartinez
Copy link
Member Author

Ok .. easy enough to just expose an event :)

Good point on the gyro, I'll incorporate that as well. Will send another checkin when I can!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants