Optimistic UI on non-Meteor stuff?


I’ve got a billing page where the user can change their default credit card, which calls the Stripe API. I’m guessing optimistic UI only works for Meteor data sources? In other words, I have to fake optimistic UI by doing the following:

  setDefaultCard = (cardId) => {
    const oldId = this.state.defaultCardId;

    // Optimistic UI
    this.setState({ defaultCardId: cardId });

    this.props.setDefaultCard(cardId, (error, result) => {
      if (!error) {
          defaultCardId: result.default_source,
      } else {
        this.setState({ defaultCardId: oldId });

In the method, doing something like if (this.isSimulation) return { default_source: cardId } doesn’t quite do what I’d expected.


I think it’s only implemented in MiniMongo