Optimistic UI on non-Meteor stuff?


#1

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) {
        this.setState({
          defaultCardId: result.default_source,
        });
      } else {
        console.error(error);
        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.


#2

I think it’s only implemented in MiniMongo