incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Becky Gibson <>
Subject Hack to compass.js to support iOS watchHeadingFilter
Date Tue, 03 Apr 2012 20:25:48 GMT
As discussed on this list,  I added back support for the iOS watch compass
heading by filter method by "extending" the unified JS Compass.watchFilter
and getCurrentHeading() methods.   Frankly, I think this is a bit of a hack
but it works.  If the call to watchHeading contains an options.filter
parameter and it is > 0, I call getCurrentHeading with that options object
and do not set up a interval to repeatedly call getCurrentHeading.  I hack
a "special" value into the timers array so that when a clearWatch is
called, I know to call Compass.stopHeading rather than just clearing the

The issue is that sometimes getCurrentHeading is called with an options
object and other times options is undefined.  I don't see any issues on iOS
calling exec with the undefined options param.  Need someone to verify this
on Android.  Also, this breaks the unit tests, and not being familiar with
Jasmine, wasn't sure how to deal with an "optional" parameter?   So, could
use some advice on how to handle that.  I could also make it a bit more
"pure" and only pass the options parameter when it is legitimate or pass
null with it was not passed in.  Looking for suggestions as to how best to
fix this and modify the tests to pass before I check in.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message