mirror of
https://github.com/pebble-dev/clay.git
synced 2026-09-02 15:17:44 -04:00
Merge remote-tracking branch 'origin/master' into #47/range-slider-component
# Conflicts: # index.js
This commit is contained in:
@@ -662,16 +662,27 @@ Pebble.addEventListener('webviewclosed', function(e) {
|
||||
|
||||
### `Clay([Array] config, [function] customFn, [object] options)`
|
||||
|
||||
#### Constructor Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|----------|-------|-------------|
|
||||
| `config` | Array | The config that will be used to generate the configuration page |
|
||||
| `customFn` | Function\|null | (Optional) The [custom function](#custom-function) to be injected into the generated configuration page. |
|
||||
| `options` | Object | (Optional) See below for properties |
|
||||
| `options.autoHandleEvents` | Boolean | (Optional) Defaults to `true`. If set to `false`, Clay will not [auto handle the `showConfiguration` and `webviewclosed` events](#handling-the-showconfiguration-and-webviewclosed-events-manually) |
|
||||
| `options.userData` | Any | (Optional) Any arbitrary data you want to pass to your config page. It will be available in your custom function as `this.meta.userData` |
|
||||
|
||||
#### Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
|----------|------|-------------|
|
||||
| `.config` | Array | Reference to the config passed to the constructor and used for generating the page. **WARNING** this is a direct reference, not a copy of the config so any modification you make to it, will be reflected on the original as well |
|
||||
| `.config` | Array | Copy of the config passed to the constructor and used for generating the page. |
|
||||
| `.customFn` | Function | Reference to the custom function passed to the constructor. **WARNING** this is a direct reference, not a copy of the custom function so any modification you make to it, will be reflected on the original as well |
|
||||
| `.meta` | Object | Contains information about the current user and watch. **WARNING** This will only be populated in the `showConfiguration` event handler. (See example above) |
|
||||
| `.meta.activeWatchInfo` | watchinfo\|null | An object containing information on the currently connected Pebble smartwatch or null if unavailable. Read more [here](https://developer.pebble.com/docs/js/Pebble/#getActiveWatchInfo). |
|
||||
| `.meta.accountToken` | String | A unique account token that is associated with the Pebble account of the current user. Read more [here](https://developer.pebble.com/docs/js/Pebble/#getAccountToken). |
|
||||
| `.meta.watchToken` | String | A unique token that can be used to identify a Pebble device. Read more [here](https://developer.pebble.com/docs/js/Pebble/#getWatchToken). |
|
||||
| `.meta.userData` | Any | A deep copy of the arbitrary data provided in the `options.userData`. Defaults to an empty object |
|
||||
|
||||
#### Methods
|
||||
|
||||
@@ -703,7 +714,8 @@ Make sure to always wait for the config page to be built before manipulating ite
|
||||
var Clay = require('./clay');
|
||||
var clayConfig = require('./config');
|
||||
var customClay = require('./custom-clay');
|
||||
var clay = new Clay(clayConfig, customClay);
|
||||
var userData = {token: 'abc123'}
|
||||
var clay = new Clay(clayConfig, customClay, {userData: userData});
|
||||
```
|
||||
|
||||
##### custom-clay.js
|
||||
@@ -732,6 +744,15 @@ module.exports = function(minified) {
|
||||
if (!clayConfig.meta.activeWatchInfo || clayConfig.meta.activeWatchInfo.platform === 'aplite') {
|
||||
clayConfig.getItemByAppKey('background').hide();
|
||||
}
|
||||
|
||||
// Set the value of an item based on the userData
|
||||
$.request('get', 'https://some.cool/api', {token: clayConfig.meta.userData.token})
|
||||
.then(function(result) {
|
||||
// Do something interesting with the data from the server
|
||||
})
|
||||
.error(function(status, statusText, responseText) {
|
||||
// Handle the error
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
@@ -754,6 +775,7 @@ This is the main way of talking to your generated config page. An instance of th
|
||||
| `.meta.activeWatchInfo` | watchinfo\|null | An object containing information on the currently connected Pebble smartwatch or null if unavailable. Read more [here](https://developer.pebble.com/docs/js/Pebble/#getActiveWatchInfo). |
|
||||
| `.meta.accountToken` | String | A unique account token that is associated with the Pebble account of the current user. Read more [here](https://developer.pebble.com/docs/js/Pebble/#getAccountToken). |
|
||||
| `.meta.watchToken` | String | A unique token that can be used to identify a Pebble device. Read more [here](https://developer.pebble.com/docs/js/Pebble/#getWatchToken). |
|
||||
| `.meta.userData` | Any | The data passed in the `options.userData` of the [Clay constructor.](#clayarray-config-function-customfn-object-options) |
|
||||
|
||||
|
||||
#### Methods
|
||||
|
||||
Reference in New Issue
Block a user