cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robpaveza <...@git.apache.org>
Subject [GitHub] cordova-plugin-vibration pull request: CB-9365 Add support for 'vi...
Date Thu, 03 Sep 2015 17:11:04 GMT
Github user robpaveza commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-vibration/pull/38#discussion_r38670056
  
    --- Diff: src/windows/VibrationProxy.js ---
    @@ -60,12 +61,43 @@ if (VibrationDevice) {
                     fail(e);
                 }
             }, 
    -        vibrateWithPattern: function(success, fail, args) {
    -            // TODO: Implement with setTimeout.
    -            fail('"vibrateWithPattern" is unsupported by this platform.');
    +        vibrateWithPattern: function (success, fail, args) {
    +            // Cancel current vibrations first
    +            module.exports.cancelVibration(function () {
    +                // Removes the first zero
    +                if (args[0] && args[0][0] === 0) {
    +                    args[0].shift(0);
    +                }
    +
    +                patternChainPromise = args[0].reduce(function (previousValue, currentValue,
index) {
    +                    if (index % 2 === 0) {
    +                        return previousValue.then(function () {
    +                            return new WinJS.Promise(function (complete, error) {
    +                                module.exports.vibrate(function () {}, function(err)
{
    +                                    console.error(err);
    +                                    error(err);
    +                                }, [currentValue]);
    --- End diff --
    
    We make a lot of references to `currentValue`.  Can we just parse it once and save the
integer form?  Maybe we can opportunistically parse all of them on input and if any parse
return NaN then we fail fast.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message