[ 
https://issues.apache.org/jira/browse/CB-9365?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14729405#comment-14729405
 ] 

ASF GitHub Bot commented on CB-9365:
------------------------------------

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.


> Add support for 'vibrateWithPattern' to Windows Phone 8.1 / Windows 10
> ----------------------------------------------------------------------
>
>                 Key: CB-9365
>                 URL: https://issues.apache.org/jira/browse/CB-9365
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Vibration
>            Reporter: Rob Paveza
>            Assignee: Sergey Shakhnazarov
>            Priority: Minor
>
> 'vibrateWithPattern' is supported by C# component in wp8, but needs to be 
> migrated to Windows Phone 8.1.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to