<commit_before>package coconut.ui.internal;

import tink.state.*;
import tink.state.Observable;

using tink.CoreApi;

class Slot<T, Container:ObservableObject<T>>
  extends Invalidator implements Invalidatable implements ObservableObject<T> {

  var data:Container;
  var link:CallbackLink;

  final defaultData:Container;//TODO: this should be lazy
  final owner:{};
  final comparator:Comparator<T>;

  public var value(get, never):T;
    inline function get_value()
      return observe().value;

  public function new(owner, ?comparator, ?defaultData) {
    super();
    this.owner = owner;
    this.comparator = switch comparator {
      case null: function (a, b) return a == b;
      case v: v;
    }
    this.data = this.defaultData = defaultData;
    if (defaultData != null)
      defaultData.onInvalidate(this);
  }

  public inline function observe():Observable<T>
    return this;

  public function invalidate()
    fire();<commit_msg>Adjust to latest tink_state.<commit_after>package coconut.ui.internal;

import tink.state.*;
import tink.state.Observable;
import tink.state.Invalidatable;

using tink.CoreApi;

class Slot<T, Container:ObservableObject<T>>
  extends Invalidator implements Invalidatable implements ObservableObject<T> {

  var data:Container;
  var link:CallbackLink;

  final defaultData:Container;//TODO: this should be lazy
  final owner:{};
  final comparator:Comparator<T>;

  public var value(get, never):T;
    inline function get_value()
      return observe().value;

  public function new(owner, ?comparator, ?defaultData) {
    this.owner = owner;
    this.comparator = switch comparator {
      case null: function (a, b) return a == b;
      case v: v;
    }
    this.data = this.defaultData = defaultData;
    if (defaultData != null)
      defaultData.onInvalidate(this);
  }

  public inline function observe():Observable<T>
    return this;

  public function invalidate()
    fire();
{'fraction_non_alphanumeric': 0.10708742886704604, 'fraction_numerical': 0.0, 'mean_word_length': 3.9086294416243654, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3199368', 'n_tokens_mistral': 585, 'n_tokens_neox': 572, 'n_words': 161}