TysEvent
A window event, by type.
type TysEvent = | { type: "ready"; product: string } | { type: "open"; product: string } | { type: "close"; product: string } | { type: "size"; selection: SizeSelection } | { type: "loaderror"; code: string; message: string };Example
Section titled “Example”const sub = addEventListener((e) => { if (e.type === "size") setSize(e.selection.size); if (e.type === "loaderror") console.warn(e.code);});let sub = tys.on { event in switch event { case .size(let selection): selectedSize = selection.size // "Use this size" case .loadError(let error): print(error.code) default: break }}val sub = tys.on { event -> when (event) { is TryYourSize.Event.Size -> selected = event.selection.size is TryYourSize.Event.LoadError -> Log.w("tys", event.error.code.wire) else -> Unit }}tys.events.listen((e) { if (e is SizeSelected) setState(() => size = e.selection.size); if (e is LoadError) debugPrint(e.error.code);});Was this page helpful?
Thank you. We read every answer.