nw-skeleton

Class: MessageHandlersBase

mainScript. MessageHandlersBase

Base class for message handling utility classes

Extends

Methods

_doLog(message, type, data, forceToWindow){undefined}

Parameters

Name Type Description
message string Message to be logged
type string Type of log message (debug, info, warning, error, group, groupCollaped, groupend)
data array An array of data strings that are to be applied to logging message
forceToWindow Boolean Flag to force logging to main window console

Return

Logs data to console

addBoundMethods(){undefined}

Return

Method that sets up this.boundMethods property by binding this objects functions to itself to be used as event listener handlers

createDirFileRecursive(fileName, mode, options, data){Boolean}

Parameters

Name Type Description
fileName string Absolute path to file
mode Number Octal mode definition (i.e. 0o775)
options Object Options object for fs.writeFileSync
data string Data to write to file

Return

Creates directory (recursive) and writes file to it

createDirRecursive(directory, mode){Boolean}

Parameters

Name Type Description
directory string Absolute directory path
mode Number Octal mode definition (i.e. 0o775)

Return

Creates directory recursively

execute(instruction, uuid, messageData){Boolean}

Parameters

Name Type Description
instruction string Message instruction
uuid string UUID of the message
messageData Object Data passed with message

Return

Executes received (async or sync) message based on message data

finalize(){Boolean}

Return

Finalizes current class instance, setting up any additional properties etc. Entire app structure, including frontend app is available here

formatTimeNormalize(date, options, includeDate, omitSeconds){string}

Parameters

Name Type Description
date Date Date value to format
options Object Date format options
includeDate Boolean Flag to indicate whether to include date
omitSeconds Boolean Flag to indicate whether to omit seconds

Return

Format time normalized (Y-m-d H:i:s format)

getConfig(name, defaultValue){mixed}

Parameters

Name Type Description
name string String representing path to requested var (i.e. 'appConfig.appInfo.name')
defaultValue mixed Default value to be returned if configuration var is not found

Return

Returns configuration var value

getHelper(name){Object}

Parameters

Name Type Description
name string Name of the helper

Return

Returns instance of helper object based on passed parameter (or false if helper can't be found)

getStateVar(varPath, defaultValue){mixed}

Parameters

Name Type Description
varPath string String representing path to requested var (i.e. 'appData.appMainData.cancelable')
defaultValue mixed Default value to be returned if appState var is not found

Return

Returns appState var value

infoHandler(uuid, messageData, simulate){undefined}

Parameters

Name Type Description
uuid string UUID of the message
messageData Object Data passed with message
simulate Boolean Just simulate and return responseData, don't actually do or change anything

Return

Simple info handler - responds with array of handler method names

initializeLogging(){BaseClass}

Return

Determines whether logging for this class is regulated through configuration, setting the logging by it (or warning if there are no configuration settings for this class)

log(message, type, data, force, forceToWindow){undefined}

Parameters

Name Type Description
message string Message to be logged
type string Type of log message (debug, info, warning, error, group, groupCollaped, groupend)
data array An array of data strings that are to be applied to logging message
force Boolean Flag to force logging output even if config does not allow it
forceToWindow Boolean Flag to force logging to main window console

Return

Logs message to console or stdout

printLog(message, type){undefined}

Parameters

Name Type Description
message string Message to print
type string Type of message

Return

Prints message to stdout with newline appended

respond(data, simulate){undefined}

Parameters

Name Type Description
data Object Data to send with response
simulate Boolean Just simulate and return responseData, don't log anything.

Return

Sends message response along with passed data