onRecommendation()
The recommendation now (once known) and on every change: signing in, a new body, a simulation finishing.
Stream<Recommendation> onRecommendation(String product)Parameters
Section titled “Parameters”productStringRequiredYour product ID or SKU.
Returns
Section titled “Returns”A stream: the recommendation now (once known) and on every change. Cancel the subscription when done.
Example
Section titled “Example”final sub = tys.onRecommendation('SKU-123').listen((rec) { if (rec.status == RecommendationStatus.ready && !touched) setState(() => size = rec.size);});// sub.cancel() in dispose()let sub = tys.onRecommendation(for: "SKU-123") { rec in if rec.status == .ready, !touched { selectedSize = rec.size }}// keep `sub`; sub.cancel() when the screen goes awayval sub = tys.onRecommendation("SKU-123") { rec -> if (rec.status == Recommendation.Status.READY && !touched) selected = rec.size}// sub.cancel() in onDestroyuseEffect(() => { const sub = addRecommendationListener("SKU-123", (rec) => { if (rec.status === "ready" && !touched) setSize(rec.size); }); return () => sub.remove();}, []);Was this page helpful?
Thank you. We read every answer.