onRecommendation(for:onError:_:)
Esta página aún no está disponible en tu idioma.
Calls handler now (once known) and on every change: signing in, a new body, a simulation finishing. Keep the subscription; cancel() it when done.
@discardableResultpublic func onRecommendation(for product: String, onError: ((TryYourSizeError) -> Void)? = nil, _ handler: @escaping (Recommendation) -> Void) -> TYSSubscriptionParameters
Section titled “Parameters”forStringObligatorioYour product ID or SKU.
onError((TryYourSizeError) -> Void)?Opcional= nilCalled when our window cannot be reached or the app is not registered.
handler@escaping (Recommendation) -> VoidObligatorioCalled now (once known) and on every change.
Returns
Section titled “Returns”A subscription: keep it, and cancel() it when you are done.
Example
Section titled “Example”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();}, []);final sub = tys.onRecommendation('SKU-123').listen((rec) { if (rec.status == RecommendationStatus.ready && !touched) setState(() => size = rec.size);});// sub.cancel() in dispose()¿Te ha resultado útil esta página?
Gracias. Leemos todas las respuestas.