Using nativescript-particle in a javascript file


I’m wondering if anyone has used the nativescript-particle plugin in a javascript (not typescript) file before, and if so could they shed any light on whatever rookie mistake I must be making.

I’ve got the following in my view-model.js in a basic templated program.

const observableModule = require("tns-core-modules/data/observable");
const ParticleModule = require("nativescript-particle");
const particle = new ParticleModule.Particle();
function HomeItemsViewModel() {
	var viewModel = observableModule.fromObject({
		items: [
				name: "Item A",
				description: "Description for Item 1"
				name: "Item B",
				description: "Description for Item 2"

	const token = 'XXXXXXXXXXXXXXXXX';

		.then(devices => {
			viewModel.items[1].name = devices.length.toString();
		.catch(error => {
			console.log(`Error fetching devices: ${error}`);
			viewModel.items[1].name = error;

    return viewModel;
module.exports = HomeItemsViewModel;

And I just get the unchanged “Item B”, so it appears that the particle functions are not called at all.
Tried a very similar thing in a typescript version of this project and it worked.

What am I not doing right?

Actually putting:
dialogs.alert(Then ${items.length} - ${items[0].name});
into the then branch gets me the device name, so the function is called, it’s just not being assigned to the observable, so that’s better at least…