<commit_before>package isabelle.eclipse.launch.tabs

import scala.collection.mutable.Publisher


/**
 * Utilities for observables and publisher/subscribe functionality
 * 
 * @author <NAME>
 */
object ObservableUtil {

  /**
   * An implicit class that adds a simpler subscribe method to publisher 
   */
  implicit class NotifyPublisher[Evt](pub: Publisher[Evt]) {

    def subscribeFun(sub: Evt => Unit) {
      pub.subscribe(new pub.Sub {
        override def notify(p: pub.Pub, event: Evt) = sub(event)
      })
    }
  }

}<commit_msg>wrappers for Publisher and ObservableValue<commit_after>package isabelle.eclipse.launch.tabs

import scala.collection.mutable.Publisher


/**
 * Utilities for observables and publisher/subscribe functionality
 * 
 * @author <NAME>
 */
object ObservableUtil {

  /**
   * An implicit class that adds a simpler subscribe method to publisher 
   */
  implicit class NotifyPublisher[Evt](pub: Publisher[Evt]) {

    def subscribeFun(sub: Evt => Unit) {
      pub.subscribe(new pub.Sub {
        override def notify(p: pub.Pub, event: Evt) = sub(event)
      })
    }
  }


  /**
   * A wrapper for Publisher that adapts the event type.
   */
  class AdapterPublisher[Evt, BaseEvt](base: Publisher[BaseEvt])(adapt: BaseEvt => Evt)
      extends Publisher[Evt] {

    // subscribe to base listener
    base.subscribe(new base.Sub {
      override def notify(p: base.Pub, event: BaseEvt) = publish(adapt(event))
    })
  }


  /**
   * A wrapper for ObservableValue that adapts the value type.
   */
  class AdapterObservableValue[V, BaseV](base: ObservableValue[BaseV])(adapt: BaseV => V)
      extends AdapterPublisher[V, BaseV](base)(adapt) with ObservableValue[V] {
    
    override def value = adapt(base.value)
  }

}
{'fraction_non_alphanumeric': 0.11269208878770631, 'fraction_numerical': 0.0, 'mean_word_length': 3.3300492610837438, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '4629917', 'n_tokens_mistral': 570, 'n_tokens_neox': 533, 'n_words': 142}