{"_id":"ovh-angular-swimming-poll","_rev":"28-688a40c97360998b93e69b3d9297911d","name":"ovh-angular-swimming-poll","dist-tags":{"latest":"3.0.0"},"versions":{"3.0.0":{"name":"ovh-angular-swimming-poll","version":"3.0.0","author":{"name":"OVH SAS"},"license":"BSD-3-Clause","_id":"ovh-angular-swimming-poll@3.0.0","maintainers":[{"name":"frisouilles","email":"kevin.bonduelle@corp.ovh.com"}],"homepage":"https://github.com/ovh-ux/ovh-angular-swimming-poll#readme","bugs":{"url":"https://github.com/ovh-ux/ovh-angular-swimming-poll/issues"},"dist":{"shasum":"496ccae4c8edbfd04719b05fe99fb98c00b1c78f","tarball":"https://registry.npmjs.org/ovh-angular-swimming-poll/-/ovh-angular-swimming-poll-3.0.0.tgz","integrity":"sha512-GWUG5a/8GutHRVQ+/rH4um3tnS/csvOWtk15KoKWdKbgTD6f1Dm96PWYRCop9L8nyPn0wCmmTwIhRxrdC7YSwQ==","signatures":[{"sig":"MEUCIQDwK4UWI2tDzH2qrjVzpXhMhjLiawxj0JolE75g/ORmxAIgGTHXqk0lIz0zb9FC7KgvbSoiR+mP7ajNcoKVxRMVMKI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./dist/ovh-angular-swimming-poll.min.js","_from":".","_shasum":"496ccae4c8edbfd04719b05fe99fb98c00b1c78f","gitHead":"78dde062cfdf2c2c4171a3140c857e456b85e3df","scripts":{"fix":"eslint --quiet --fix --ext .js .","test":"grunt test"},"_npmUser":{"name":"frisouilles","email":"kevin.bonduelle@corp.ovh.com"},"repository":{"url":"git+https://github.com/ovh-ux/ovh-angular-swimming-poll.git","type":"git"},"_npmVersion":"4.1.2","description":"A poller to swim easily to success status!","directories":{},"_nodeVersion":"7.7.1","devDependencies":{"grunt":"0.4.x","karma":"~0.12.9","eslint":"^3.19.0","matchdep":"^0.3.0","grunt-bump":"~0.3.0","grunt-karma":"~0.10.1","grunt-eslint":"^19.0.0","karma-jasmine":"~0.3.0","jshint-stylish":"~1.0.0","grunt-complexity":"~0.1.0","eslint-config-ovh":"^0.1.1","grunt-ng-annotate":"~0.10.0","grunt-autoprefixer":"~2.2.0","grunt-contrib-copy":"~0.7.0","grunt-contrib-less":"~1.0.0","grunt-contrib-clean":"~0.6.0","grunt-contrib-watch":"~0.6.1","grunt-contrib-concat":"~0.5.0","grunt-contrib-cssmin":"~0.12.2","grunt-contrib-jshint":"~0.11.0","grunt-contrib-uglify":"~0.8.0","grunt-contrib-csslint":"~0.4.0","karma-phantomjs-launcher":"~0.1.4"},"_npmOperationalInternal":{"tmp":"tmp/ovh-angular-swimming-poll-3.0.0.tgz_1498552695010_0.005768064176663756","host":"s3://npm-registry-packages"}}},"time":{"created":"2017-06-27T08:38:16.120Z","modified":"2025-12-18T14:47:53.645Z","3.0.0":"2017-06-27T08:38:16.120Z"},"bugs":{"url":"https://github.com/ovh-ux/ovh-angular-swimming-poll/issues"},"author":{"name":"OVH SAS"},"license":"BSD-3-Clause","homepage":"https://github.com/ovh-ux/ovh-angular-swimming-poll#readme","repository":{"url":"git+https://github.com/ovh-ux/ovh-angular-swimming-poll.git","type":"git"},"description":"A poller to swim easily to success status!","maintainers":[{"email":"jean-christophe.alleman@corp.ovh.com","name":"jisay"},{"email":"jean-philippe.blary@corp.ovh.com","name":"blary_jp"},{"email":"ant.leblanc@gmail.com","name":"antleblanc"},{"email":"tech.ux.ext@ovh.com","name":"ovh-ux-cds"},{"email":"cyril.biencourt@corp.ovh.com","name":"lizardk"},{"email":"opensource@ovh.net","name":"ovh"},{"email":"mariejones962@gmail.com","name":"marie-j"},{"email":"anooparveti@gmail.com","name":"anooparveti"},{"email":"helabenkhalfallah@hotmail.fr","name":"helabenkhalfallah"},{"email":"benjamin.coenen@hotmail.com","name":"bnjjj"},{"email":"giovanni.clement@gmail.com","name":"gioindahouz"},{"email":"k.ung@rduk.fr","name":"khuang"},{"email":"joffrey.leveugle@gmail.com","name":"jleveugle"},{"email":"axel.peter@live.com","name":"axelpeter"},{"email":"cyrille.bourgois@gmail.com","name":"cbourgois"}],"readme":"![githubbanner](https://user-images.githubusercontent.com/3379410/27423240-3f944bc4-5731-11e7-87bb-3ff603aff8a7.png)\n\n[![Maintenance](https://img.shields.io/maintenance/yes/2017.svg)]() [![Chat on gitter](https://img.shields.io/gitter/room/ovh/ux.svg)](https://gitter.im/ovh/ux) [![Build Status](https://travis-ci.org/ovh-ux/ovh-angular-swimming-poll.svg)](https://travis-ci.org/ovh-ux/ovh-angular-swimming-poll)\n\n[![NPM](https://nodei.co/npm/ovh-angular-swimming-poll.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/ovh-angular-swimming-poll/)\n\n# Swimming-poll\n_A poller to swim easily to success status!_\n\n\n## Features\n\n * Understand standard Task states\n * Customizable states (with object or function)\n * Can share the result between differents scopes\n * Can retry when error rejection is triggered (with retryMaxAttempts, retryCountAttempts and retryTimeoutDelay task options)\n\n## Install\n\n### NPM\n\n```\n$ npm install ovh-angular-swimming-poll --save\n```\n\n### Bower\n\n```\n$ bower install ovh-angular-swimming-poll --save\n```\n\n## Get the sources\n\n```bash\n$ git clone https://github.com/ovh-ux/ovh-angular-swimming-poll.git\n$ cd ovh-angular-swimming-poll\n$ npm install\n$ bower install\n```\n\n## How to use?\n\n### With OVH standard task\n\nThe poller can manage return from OVH Task standard. This library understand OVH status and return promise when the task is finished.\n\n```javascript\nfunction (Poller) {\n    var url = '/task/42';\n    Poller.poll(\n        url,\n        null,   // params\n        {\n            namespace: 'a_namespace',\n            method: 'get',\n            scope: $scope.$id\n        }\n    ).then(function (result) {\n        console.log('result contains http response if task status is successful');\n    }, function (result) {\n        console.log('result contains http response if task status is in error state');\n    }, function (result) {\n        console.log('result contains http response if task status is in pending state');\n    });\n```\n\n### With custom validation rules\n\nWhen you want to poll another thing that an OVH task, you had to define your custom validation rules.\n\n```javascript\nfunction (Poller) {\n    var url = '/ip/192.168.1.1/status';\n    Poller.poll(\n        url,\n        {\n            headers: 'demo'\n        },\n        {\n            namespace: 'a_namespace',\n            method: 'get',\n            scope: $scope.$id,\n            successRule: { \n                status: 'yeah_it_works', \n                billingStatus : function (elem) {\n                    return elem.billing.status === 'nietMeerGeld';\n                }\n            },\n            errorRule: { \n                status: 'oh_damned',\n                billingStatus : function (elem) {\n                    return elem.billing.status === 'verdom';\n                }\n            }\n        }\n    ).then(function (result) {\n        console.log('result contains http response if status is yeah_it_works');\n    }, function (result) {\n        console.log('result contains http response if status is oh_damned');\n    }, function (result) {\n        console.log('result contains http response if status is not oh_damned and not yeah_it_works');\n    });\n```\n\n### With custom validations rules, on a listing\n\nYou can do a polling on listing request. In this case:\n * promise will return success when all elements of the list are successful.\n * promise will return error when one element or more in the list is in error state and all other are in success state\n * else, promise will send a notify with the http response\n\n```javascript\nfunction (Poller) {\n    var url = '/ip';\n    Poller.poll(\n        url,\n        {\n            headers: 'demo'\n        },\n        {\n            namespace: 'a_namespace',\n            method: 'get',\n            scope: $scope.$id,\n            successRule: { \n                status: 'yeah_it_works', \n                billingStatus : function (elem) {\n                    return elem.billing.status === 'nietMeerGeld';\n                }\n            },\n            errorRule: { \n                status: 'oh_damned',\n                billingStatus : function (elem) {\n                    return elem.billing.status === 'verdom';\n                }\n            }\n        }\n    ).then(function (result) {\n        console.log('result contains http response if all statuses are yeah_it_works');\n    }, function (result) {\n        console.log('result contains http response if one or more status is oh_damned and other yeah_it_works');\n    }, function (result) {\n        console.log('result contains http response if one or more status is not a finalized status');\n    });\n```\n\n### With time interval\n\nYou can specify the interval as a fix value or a function\n\n```javascript\nfunction (Poller) {\n    var url = '/task/42';\n    Poller.poll(\n        url,\n        null,   // params\n        {\n            namespace: 'a_namespace',\n            method: 'get',\n            scope: $scope.$id,\n            interval: function(iteration) {\n                return 10 * Math.exp(iteration);\n            }\n        }\n    ).then(function (result) {\n        console.log('result contains http response if task status is successful');\n    }, function (result) {\n        console.log('result contains http response if task status is in error state');\n    }, function (result) {\n        console.log('result contains http response if task status is in pending state');\n    });\n```\n\n# Contributing\n\nYou've developed a new cool feature ? Fixed an annoying bug ? We'd be happy\nto hear from you !\n\nHave a look in [CONTRIBUTING.md](https://github.com/ovh-ux/ovh-angular-swimming-poll/blob/master/CONTRIBUTING.md)\n\n## Run the tests\n\n```\n$ npm test\n```\n\n## Related links\n\n * Contribute: https://github.com/ovh-ux/ovh-angular-swimming-poll/blob/master/CONTRIBUTING.md\n * Report bugs: https://github.com/ovh-ux/ovh-angular-swimming-poll/issues\n * Get latest version: https://github.com/ovh-ux/ovh-angular-swimming-poll\n\n# License\n\nSee https://github.com/ovh-ux/ovh-angular-swimming-poll/blob/master/LICENSE\n","readmeFilename":"README.md"}