onRecommendation()
Calls handler now (once known) and on every change: signing in, a new body, a simulation finishing. Keep the subscription; cancel() it when done. Main thread.
@JvmOverloadspublic fun onRecommendation( product: String, onError: ((TryYourSizeException) -> Unit)? = null, handler: (Recommendation) -> Unit, ): TysSubscriptionParameters
Section titled “Parameters”productStringRequiredYour product ID or SKU.
onError((TryYourSizeException) -> Unit)?Optional= nullCalled when our window cannot be reached or the app is not registered.
handler(Recommendation) -> UnitRequiredCalled now (once known) and on every change.
Returns
Section titled “Returns”A subscription; cancel() it when done.
Example
Section titled “Example”val sub = tys.onRecommendation("SKU-123") { rec -> if (rec.status == Recommendation.Status.READY && !touched) selected = rec.size}// sub.cancel() in onDestroylet sub = tys.onRecommendation(for: "SKU-123") { rec in if rec.status == .ready, !touched { selectedSize = rec.size }}// keep `sub`; sub.cancel() when the screen goes awayuseEffect(() => { const sub = addRecommendationListener("SKU-123", (rec) => { if (rec.status === "ready" && !touched) setSize(rec.size); }); return () => sub.remove();}, []);final sub = tys.onRecommendation('SKU-123').listen((rec) { if (rec.status == RecommendationStatus.ready && !touched) setState(() => size = rec.size);});// sub.cancel() in dispose()Was this page helpful?
Thank you. We read every answer.