Skip to content

Bindings

Egor Badmaev edited this page Feb 5, 2023 · 1 revision

Observable

A type of object that publishes a message after the object has changed.

Declaration

final class Observable<T>

Overview

Simple binding implementation Observable properties.

T is a generic type of anything. You can make any type observable.

Topics

init(value: T)

func bind(_ listener: @escaping Listener)

var value: T

typealias Listener = (T) -> Void

Tests

Tests' file

Test changing value w/ binding

  1. Bind some handler that will set new value to the variable
  2. Check that value has changed

Test changing value w/o binding

Same thing as previous one, but w/o binding, so the value won't change