slackpost.js
function SlackState(n) {
    RED.nodes.createNode(this, n);

    var node = this;
    this.client = n.client;
    this.clientNode = RED.nodes.getNode(this.client);

    node.status(statuses.disconnected);

    if (node.client) {
      SetConfigNodeConnectionListeners(node);

      node.on("input", function(msg) {
        SlackDebug("slack-state incomiming message", msg);

        node.status(statuses.sending);

        /**
         * support for forcing a refresh of data
         */
        if (msg.payload === true) {
          node.clientNode
            .refreshState()
            .then(() => {
              msg.slackState = node.clientNode.state;
              node.send(msg);
              node.status(statuses.connected);
            })
            .catch(e => {
              SlackDebug("slack-state error response", e.data);
              msg.payload = e.data;
              node.send(msg);
              node.status(statuses.connected);
            });
        } else {
          msg.slackState = node.clientNode.state;
          node.send(msg);
          node.status(statuses.connected);
        }
      });

      ["state_initialized"].forEach(eventName => {
        node.clientNode.on(eventName, e => {
          node.status(statuses.sending);
          var msg = {};

          switch (eventName) {
            case "state_initialized":
              eventName = "ready";
              break;
          }

          msg.slackState = node.clientNode.state;
          msg.payload = {
            type: eventName
          };
          node.send([null, msg]);
          node.status(statuses.connected);
        });
      });
    } else {
      node.status(statuses.misconfigured);
    }
  }
function SlackState(n) {
    RED.nodes.createNode(this, n);

    var node = this;
    this.client = n.client;
    this.clientNode = RED.nodes.getNode(this.client);

    node.status(statuses.disconnected);

    if (node.client) {
      SetConfigNodeConnectionListeners(node);

      node.on("input", function(msg) {
        SlackDebug("slack-state incomiming message", msg);

        node.status(statuses.sending);

        /**
         * support for forcing a refresh of data
         */
        if (msg.payload === true) {
          node.clientNode
            .refreshState()
            .then(() => {
              msg.slackState = node.clientNode.state;
              node.send(msg);
              node.status(statuses.connected);
            })
            .catch(e => {
              SlackDebug("slack-state error response", e.data);
              msg.payload = e.data;
              node.send(msg);
              node.status(statuses.connected);
            });
        } else {
          msg.slackState = node.clientNode.state;
          node.send(msg);
          node.status(statuses.connected);
        }
      });

      ["state_initialized"].forEach(eventName => {
        node.clientNode.on(eventName, e => {
          node.status(statuses.sending);
          var msg = {};

          switch (eventName) {
            case "state_initialized":
              eventName = "ready";
              break;
          }

          msg.slackState = node.clientNode.state;
          msg.payload = {
            type: eventName
          };
          node.send([null, msg]);
          node.status(statuses.connected);
        });
      });
    } else {
      node.status(statuses.misconfigured);
    }
  }
function SlackState ( n ) { RED . nodes . createNode ( this , n ) ; var node = this ; this . client = n . client ; this . clientNode = RED . nodes . getNode ( this . client ) ; node . status ( statuses . disconnected ) ; if ( node . client ) { SetConfigNodeConnectionListeners ( node ) ; node . on ( "input" , function ( msg ) { SlackDebug ( "slack-state incomiming message" , msg ) ; node . status ( statuses . sending ) ; /**
         * support for forcing a refresh of data
         */ if ( msg . payload === true ) { node . clientNode . refreshState ( ) . then ( ( ) => { msg . slackState = node . clientNode . state ; node . send ( msg ) ; node . status ( statuses . connected ) ; } ) . catch ( e => { SlackDebug ( "slack-state error response" , e . data ) ; msg . payload = e . data ; node . send ( msg ) ; node . status ( statuses . connected ) ; } ) ; } else { msg . slackState = node . clientNode . state ; node . send ( msg ) ; node . status ( statuses . connected ) ; } } ) ; [ "state_initialized" ] . forEach ( eventName => { node . clientNode . on ( eventName , e => { node . status ( statuses . sending ) ; var msg = { } ; switch ( eventName ) { case "state_initialized" : eventName = "ready" ; break ; } msg . slackState = node . clientNode . state ; msg . payload = { type : eventName } ; node . send ( [ null , msg ] ) ; node . status ( statuses . connected ) ; } ) ; } ) ; } else { node . status ( statuses . misconfigured ) ; } }
Send the current state of the config object out

@param {*} n
Send the current state of the config object out