Return part of a function first then do the rest


#1

I have this function:

  handleClickSuitClass(rankClass, suitClass) {
    // first part I'd like to run AND return no matter what
    const newState = update(this.state, { [rankClass]: { [suitClass]: { $set: !this.state[rankClass][suitClass] } } });
    this.setState(newState);

    // second part I'd like to run after first part returned
    const presetId = this.state.preset.current;
    if (presetId !== '') {
      updateSuitClass.call({ _id: presetId, rankClass, suitClass }, (err) => {
        if (err) {
          Bert.alert(err.reason, 'danger');
          const revertState = update(this.state, { [rankClass]: { [suitClass]: { $set: !this.state[rankClass][suitClass] } } });
          this.setState(revertState);
        }
      });
    }
  }

I want the first two lines to run no matter what, which is to setState on a state that toggles check (tick) mark on the item that has been clicked.

Then (after first part returned) if true make a call to Meteor validated method to update item as checked on the database. If there’s an error, revert back to original state by toggling state again.

Currently it works, but it’s slow. How can I make it so that first two lines gets run first and sets state, then run the second part after in a single function?