ember-particle
is an addon for Ember.js providing an injectable service that acts as a wrapper around the Particle API.
ember install ember-particle
ember-particle
enables all functions identical to their API as it is just a wrapper.
Complete API docs for all Particle.io methods are available at the JS SDK doc site https://docs.particle.io/reference/javascript/
Login a user with a username and password:
//...
import { inject as service } from '@ember/service';
export default Controller.extend({
particle: service('particle'),
actions: {
loginToParticle(username, password) {
this.get('particle')
.login(username, password)
.then((success) => {
alert('you logged into particle! huzzah!');
})
.catch((error) => {
alert('Something went terribly wrong', error);
});
}
}
});
List devices for a user
//...
import { inject as service } from '@ember/service';
export default Controller.extend({
particle: service('particle'),
devices: this.get('particle').listDevices()
});
Gets all attributes for a device
//...
import { inject as service } from '@ember/service';
export default Controller.extend({
particle: service('particle'),
device: this.get('particle').getDevice('asdf1234')
});
I'm always happy to take on PRs. Here is how to get up and running:
git clone https://github.com/mileszim/ember-particle
this repositorycd ember-particle
yarn install
npm run lint:hbs
npm run lint:js
npm run lint:js -- --fix
ember test
– Runs the test suite on the current Ember versionember test --server
– Runs the test suite in "watch mode"ember try:each
– Runs the test suite against multiple Ember versions
ember serve
- Visit the dummy application at http://localhost:4200.
For more information on using ember-cli, visit https://ember-cli.com/.
This project is licensed under the MIT License.