Retree - v1.0.0
    Preparing search index...

    Function createRetreeConvexMutation

    • Create a typed Retree Convex mutation function from a Convex client and mutation reference.

      Type Parameters

      Parameters

      Returns RetreeConvexMutation<Mutation>

      A typed mutation function with optional optimistic update support.

      Use this when you need a typed mutation helper outside a BaseConvexNode. Mutations are imperative calls and do not emit Retree changes by themselves. Pair with withOptimisticUpdate to update a query node immediately, or wait for a subscribed query to emit the server value.

      const toggleCompleted = createRetreeConvexMutation(
      client,
      api.tasks.toggleCompleted
      );

      await toggleCompleted(
      { taskId },
      {
      withOptimisticUpdate: (ctx) => {
      tasks.optimisticUpdate({
      ctx,
      apply(items) {
      const task = items.find((item) => item._id === taskId);
      if (task) task.isCompleted = !task.isCompleted;
      },
      });
      },
      }
      );