From a474ef9eefdf53dfabf2f3b5364a4fb29fab2714 Mon Sep 17 00:00:00 2001 From: Stanimir Karoserov Date: Mon, 19 May 2014 11:31:13 +0300 Subject: [PATCH] location snippets documentation update --- Tests/location-tests.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Tests/location-tests.ts b/Tests/location-tests.ts index a2b567b59..45fd92518 100644 --- a/Tests/location-tests.ts +++ b/Tests/location-tests.ts @@ -150,3 +150,35 @@ export var testLocationOnceMaximumAge = function () { export var testLocationOnceTimeout1000 = function () { doOnce({ timeout: 1000 }); }; + +export var testSnippet = function () { + var locationReceived; + // + // ### Get location once + // if there is `options.timeout` you will receive error on timeout. If `options.timeout` is 0 then the result is the same as the result from `LocationManager.lastKnownLocation` + // and there will be no wait. You can use `options.maximumAge` to specify you don't want to receive locations older than specified time in ms. + // + // ``` JavaScript + // var locationModule = require("location"); + //// options can also look like { maximumAge: 2000, timeout: 20 } + locationModule.getLocation({ maximumAge: 30000, timeout: 0 }).then(function (location) { + //console.log('Location received: ' + location); + // + locationReceived = true; + // + }).fail(function (error) { + //console.log('Location error received: ' + error); + // + locationReceived = error; + // + }); + // ``` + // + + var isReady = function () { + return locationReceived; + } + + TKUnit.waitUntilReady(isReady, 10); +}; +