src/lib/cloud-provider.js
/**
     * Format and send a message to the cloud data server.
     * @param {string} methodName The message method, indicating the action to perform.
     * @param {string} dataName The name of the cloud variable this message pertains to
     * @param {string | number} dataValue The value to set the cloud variable to
     * @param {number} dataIndex The index of the item to update (for cloud lists)
     * @param {string} dataNewName The new name for the cloud variable (if renaming)
     */
Format and send a message to the cloud data server.
@param {string} methodName The message method, indicating the action to perform.
@param {string} dataName The name of the cloud variable this message pertains to
@param {string | number} dataValue The value to set the cloud variable to
@param {number} dataIndex The index of the item to update (for cloud lists)
@param {string} dataNewName The new name for the cloud variable (if renaming)
Format and send a message to the cloud data server . @param { string } methodName The message method indicating the action to perform . @param { string } dataName The name of the cloud variable this message pertains to @param { string | number } dataValue The value to set the cloud variable to @param { number } dataIndex The index of the item to update ( for cloud lists ) @param { string } dataNewName The new name for the cloud variable ( if renaming )
writeToServer (methodName, dataName, dataValue, dataIndex, dataNewName) {
        const msg = {};
        msg.method = methodName;
        msg.user = this.username;
        msg.project_id = this.projectId;
        if (dataName) msg.name = dataName;
        if (dataNewName) msg.new_name = dataNewName;
        if (typeof dataValue !== 'undefined') msg.value = dataValue;
        if (typeof dataValue !== 'undefined') msg.index = dataIndex;
        const dataToWrite = JSON.stringify(msg);
        this.sendCloudData(dataToWrite);
    }
writeToServer ( methodName , dataName , dataValue , dataIndex , dataNewName ) { const msg = { } ; msg . method = methodName ; msg . user = this . username ; msg . project_id = this . projectId ; if ( dataName ) msg . name = dataName ; if ( dataNewName ) msg . new_name = dataNewName ; if ( typeof dataValue !== 'undefined' ) msg . value = dataValue ; if ( typeof dataValue !== 'undefined' ) msg . index = dataIndex ; const dataToWrite = JSON . stringify ( msg ) ; this . sendCloudData ( dataToWrite ) ; }
Format and send a message to the cloud data server.
Format and send a message to the cloud data server .
// Optional string params can use simple falsey undefined check // Optional number params need different undefined check