05-22-2019 15:45
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-22-2019 15:45
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I'm coding a clock face app. Here's the code:
import clock from "clock";
import document from "document";
import { preferences } from "user-settings";
import * as util from "../common/utils";
import { today } from "user-activity";
import { HeartRateSensor } from "heart-rate";
let heartRate = document.getElementById("heartRate");
heartRate.text = "-";
var hrm = new HeartRateSensor();
hrm.onreading = function() {
// Peek the current sensor values
heartRate.text = hrm.heartRate;
console.log("Current heart rate: " + hrm.heartRate);
hrm.stop()
hrm.start()
// Update the clock every minute
clock.granularity = "seconds";
let txtSteps = document.getElementById("txtSteps");
// inside the clock tick handler
txtSteps.text = today.adjusted.steps || 5;
// Get a handle on the <text> element
const myLabel = document.getElementById("myLabel");
// Update the <text> element every tick with the current time
clock.ontick = (evt) => {
let today = evt.date;
let hours = today.getHours();
if (preferences.clockDisplay === "12h") {
// 12h format
hours = hours % 12 || 12;
} else {
// 24h format
hours = util.zeroPad(hours);
}
let mins = util.zeroPad(today.getMinutes());
myLabel.text = `${hours}:${mins}`;
}
It comes out with this:
- TS1005: '}' expected.
- Error: Failed to compile /project/app/index.js
- Details: id: /project/app/index.js hook: transform code: PLUGIN_ERROR
I have a } at the end, like it wants me to have.
I'm new to this, please help!
Answered! Go to the Best Answer.
Accepted Solutions
05-23-2019 12:04
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-23-2019 12:04
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
For the heart rate sensor, you have the function on reading hrm with an open bracket -
@FunGamer wrote:var hrm = new HeartRateSensor();
hrm.onreading = function() {
but haven't given the closing brackets } for this function.

05-22-2019 17:43
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


05-22-2019 17:43
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
The SDK Developer Board is a place to more likely get help with this.

05-23-2019 12:04
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-23-2019 12:04
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
For the heart rate sensor, you have the function on reading hrm with an open bracket -
@FunGamer wrote:var hrm = new HeartRateSensor();
hrm.onreading = function() {
but haven't given the closing brackets } for this function.

03-23-2020 15:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-23-2020 15:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Oh, I did not look through the code lol, thanks for that!

