Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

List of components and objects that can be imported

ANSWERED

The API docs didn't seem to list out all the components/libraries and their classes/objects that can be imported. 

 

For example, I want to use localStorage or storage.LiveStorage. What component should I import? What object/class in that component can I use? 

 

Also, to use HR sensor, I saw sample code has the following line

    import { HeartRateSensor } from "heart-rate";

Without such sample code, just relying on the API docs, can I figure out what is the name of that component and the object/class? It is also unclear whether I need create an instance of that class, or there is an existing singleton object. 

Best Answer
1 BEST ANSWER

Accepted Solutions

We're working on improving the documentation, specifically in those areas. The update is coming soon, thanks for your feedback.

 

 

import { localStorage } from "local-storage"

// set the value for a key
localStorage.setItem("myKey", "myValue")

// get the value for a key
console.log(`myKey=${localStorage.getItem("myKey")}`)

 

 

import { HeartRateSensor } from "heart-rate";
let heartRateSensor = new HeartRateSensor(); heartRateSensor.start(); heartRateSensor.onreading = () => { console.log(`Current heart rate: ${heartRateSensor.heartRate}`); }

 

View best answer in original post

Best Answer
2 REPLIES 2

We're working on improving the documentation, specifically in those areas. The update is coming soon, thanks for your feedback.

 

 

import { localStorage } from "local-storage"

// set the value for a key
localStorage.setItem("myKey", "myValue")

// get the value for a key
console.log(`myKey=${localStorage.getItem("myKey")}`)

 

 

import { HeartRateSensor } from "heart-rate";
let heartRateSensor = new HeartRateSensor(); heartRateSensor.start(); heartRateSensor.onreading = () => { console.log(`Current heart rate: ${heartRateSensor.heartRate}`); }

 

Best Answer

I've been trying to figure out the heart rate sensor for the last two hours using the API documentation and I couldn't hammer it out. Most of the things in your sample code just aren't easy to find in the documentation at this moment in time. That updated info can't come fast enough. Thank goodness for this board, I'd still be stuck with a red square with 24hr time in a weird font! 

 

This helps a lot! Thanks for having all the answers!

Best Answer
0 Votes